Forum Moderators: open

Message Too Old, No Replies

How to use JS to hide CSS from non-JS browsers

         

spirelli

10:52 pm on Jan 28, 2008 (gmt 0)

10+ Year Member



I'd like to apply 0 opacity to certain images on the page, but hide it from browsers without Javascript ('cause I'll use JS to fade them in).

This in the HEAD works if I had just 1 image:

<script type="text/javascript">
document.write("<style type='text/css'>#zero {visibility:hidden;}</style>");
</script>

I could then give the image an id="zero".

However I want to do that thoughout the site with several images per page, so normally I'd like to assign them to a class, e.g. class="zero". What Javascript works for a class? Ive tried unsuccessfully:

<script type="text/javascript">
document.write("<style type='text/css'>.zero {visibility:hidden;}</style>");
</script>

Thanks for any help.

Fotiman

3:12 pm on Jan 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why don't you just use the answer to your question from this thread:
[webmasterworld.com...]