Re: changing css properties in the dom

> 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 UTC