Posted By

szsk on 08/02/06


Tagged

javascript opacity DOM alpha


Versions (?)

Who likes this?

12 people have marked this snippet as a favorite

jonhenshaw
luman
meth
malag
Hirmine
vali29
SpinZ
gbot
seanpowell
aegony
guo3823538
wirenaught


setOpacity


 / Published in: JavaScript
 

  1. function setOpacity( element, alpha ) {
  2. var style = element.style;
  3. if( style.MozOpacity != undefined ) { //Moz and older
  4. style.MozOpacity = alpha;
  5. }
  6. else if( style.filter != undefined ) { //IE
  7. style.filter = "alpha(opacity=0)";
  8. element.filters.alpha.opacity = ( alpha * 100 );
  9. }
  10. else if( style.opacity != undefined ) { //Opera
  11. style.opacity = alpha;
  12. }
  13. }

Report this snippet  

You need to login to post a comment.