Closed Thread Icon

Topic awaiting preservation: Accessing CSS pseudo-classes through the DOM (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=26981" title="Pages that link to Topic awaiting preservation: Accessing CSS pseudo-classes through the DOM (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Accessing CSS pseudo-classes through the DOM <span class="small">(Page 1 of 1)</span>\

 
Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 11-08-2005 11:22

Is this actually possible? In CSS you can use the :before pseudo-class to prepend your own bullets to an unordered list, but if, say, onClick() I wanted to change that icon, can I do that through the DOM?


Justice 4 Pat Richard

liorean
Bipolar (III) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

posted posted 11-08-2005 16:04

I'm rusty from staying out of the web development business for half a year, so my memory might fail me. But as I recall, there is no definite way. You can't do it on a per-element basis (Syntax of CSS rules in HTML's "style" attribute that purposed to change this never got past WD stage), you need to add to - or change - the stylesheets for the document.

So, first of all you need to find out a selector for the element in question. Then you need to either create a new style element and attach the rule as text, and then attach that to the document; or play around with [DOM2Style] and the iew equivalents. But trying the latter you'll soon find yourself in a tangle of different levels of support and quirkiness, so I would say the former is the better option.

--
var Liorean = {
abode: "http://codingforums.com/",
profile: "http://codingforums.com/member.php?u=5798"};

Veneficuz
Paranoid (IV) Inmate

From: A graveyard of dreams
Insane since: Mar 2001

posted posted 11-08-2005 16:18

I looked at that a couple of months ago, and didn't find anyway to do it with Javascript. What I ended up doing was using Javascript to change the class of the 'li' instead, which in the end has the same effect even though it might not be as nice

_________________________
"There are 10 kinds of people; those who know binary, those who don't and those who start counting at zero"
- the Golden Ratio - Vim Tutorial -

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 11-08-2005 19:33

Skaarj: Actually the easiest way is to, as Veneficuz said, to play with the className of the LI. But, if you *really* want to touch the :before pseudo-element, you can append/overwrite your own CSS rules using the Stylesheets object.

Hope that helps,

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 11-11-2005 16:48

Just in case, here is a tutorial to edit the Stylesheets in JavaScript

« BackwardsOnwards »

Show Forum Drop Down Menu