W3C home > Mailing lists > Public > www-style@w3.org > November 2000

Re: changing css properties in the dom

From: ValerieGSharp <ValerieGSharp@netscapeonline.co.uk>
Date: Tue, 21 Nov 2000 00:37:55 +0000
Message-ID: <3A19C3E3.90F2848F@netscapeonline.co.uk>
To: www-style@w3.org
> Chason Chaffin wrote:
> 
> this may or may not be off-topic, but this is the last place i know to
> look for an answer, since all the dhtml sites out there seem to want
> to focus on heirarchal menus and chasers.. i am trying to change the
> text size of everything encased in a p tag via javascripting.. can
> anyone give me a standards compliant way of accessing the style object
> for the p tag? i tried looking at the DOM1 on the w3c site but it's
> rather incomprehensible to me. :) thanks in advance.
> 
> -chason
> http://www.nulldesign.com/chason/


The className property of the p element can be changed dynamically.

E.g. given a couple of styles,

   .stop {color:red}
   .go {color:green}

and a p element,

   <p class="stop" id="pId">...</p>

one can change the class of the p element thus:

   document.getElementById("pId").className="go";

(See DOM2 - Appendix E: ECMA Script Language Binding: "Object
HTMLElement".)

 
-- 
Regards,
Val Sharp - Edinburgh
Received on Monday, 20 November 2000 19:37:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:06 GMT