| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
|setting CSS via JS|
| 10:10 pm on Dec 4, 2011 (gmt 0)|
var trans = 0.5;
elementid.opacity = trans;
This doesn't work either:
document.getElementById("elementid").opacity = trans;
| 11:21 pm on Dec 4, 2011 (gmt 0)|
document.getElementById("elementid").style.opacity = trans;
You will also need to set the filter property if you intend to support IE8 and below...
document.getElementById("elementid").style.filter = 'alpha(opacity=' + trans*100 + ')';
| 12:49 pm on Dec 5, 2011 (gmt 0)|
Thanks penders, that was it.
Yes, I have the IE8 code too; that came with the script and was working fine, but I couldn't convert it for other browsers. It's in a slightly different format:
elementid.filters( "alpha" ).opacity = 50;
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved