[thelist] javascript - changing css with javascript

Duncan O'Neill dbaxo at ihug.co.nz
Sun Sep 22 23:59:01 CDT 2002


Dru and Cindy Sellers wrote:
> Can anyone help me with changing css styles through javascript? my current
> iteration of my thoughts is the following:
>
> var on = false
> function cssMenu(obj) { //v0.1 by Dru Sellers
> 	if (on <> true) {
> 		obj.style.display = block
> 		on = true
> 	} else {
> 		obj.style.display = none
> 		on = false
> 	}
> }
>

Dru,

afaik, there is no '<>' operator in js. Try !=
when testing for inequality.

also, you may be able to get away with ;

function cssMenu(obj){

        if(obj.style.display=='block'){
                                        obj.style.display='none';
                                      }
        else                           {
                                        obj.style.display='block';
                                       }
}

PPK's site, is as good a starting point as any I know for DHTML;

http://www.xs4all.nl/~ppk/js/index.html


hth,
--
Duncan O'Neill
The Urban Legend magazine
http://homepages.ihug.co.nz/~dbaxo/




More information about the thelist mailing list