PDA

View Full Version : referring to css styles using javascript


awbrys
02-07-2003, 07:34 AM
Can someone point me in the direction of where I can read a tutorial on referring and changing css styles (both inline & external styles)?

I am having difficulty in understanding the basics of javascript object models and am getting very confused! For example I would like to know how to change the visibilty of the <body> tag that has been assigned a class and modified in an external css stylesheet.

Many thanks,
Awbrys.

ez4me2c3d
02-07-2003, 12:42 PM
not sure if you can modify the external CSS file but i know how to modify the style of any element.
example:<script>
document.getElementById('myTag').style.visibility = 'hidden';
</script>then your tag looks like<a href="link.html" id="myTag">Click Here</a>So you see, you can change the style of any element, just give it an ID so you call reference it.

NOTE: the style elements that are like ( z-index ) are typed ...style.zIndex, you can't use hyphens

Catman
02-07-2003, 02:10 PM
You should also note that float becomes cssFloat in JavaScript.

There are also ways to add and remove rules from style sheets, but support across browsers and platforms is too spotty to rely on that approach.