Re: Doing CSS via JavaScript
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Doing CSS via JavaScript

From: Aaron Gray <ang.usenet@gmail.com>
Date: Sat Apr 08 2006 - 23:15:55 CEST

> Aaron Gray wrote:
>> Hi,
>>
>> I have a single line of CSS that I want to do via JavaScript :-
>>
>> p { margin: 0px; }
>>
>> How do I go about this ?
>>
> It's easy to change the style on a single element in JavaScript, but in
> order to do what you want, you will have to find all the p elements and
> apply the style to each element returned.
>
> Something like (untested)
>
> var paras = document.getElementsByTagName('p');
>
> for( var i = paras.length-1; i >= ); --i )
> {
> paras[i].style.margin = '0px';
> }

No I need to alter the CSS for the document not the actual document itself.

Aaron
Received on Mon May 1 04:50:26 2006