What's new? | Help | Directory | Sign in
Google
             
Search
for
Updated Apr 14, 2008 by pilgrim
Labels: is-article, about-dom, about-css
ArticleOpacity  
HOWTO set an element's opacity (goog.style.setOpacity)

TODO intro

The code

/**
 * Sets the opacity of a node (x-browser)
 * @param {Element} el Elements
 * @param {Number} alpha Opacity between 0 and 1
 */
goog.style.setOpacity = function(el, alpha) {
  var style = el.style;
  if ('opacity' in style) {
    style.opacity = alpha;
  } else if ('MozOpacity' in style) {
    style.MozOpacity = alpha;
  } else if ('KhtmlOpacity' in style) {
    style.KhtmlOpacity = alpha;
  } else if ('filter' in style) {
    style.filter = 'alpha(opacity=' + (alpha * 100) + ')';
  }
};

The code walkthrough

TODO walkthrough

Further reading


Comment by liang2ch, May 16, 2008

good


Sign in to add a comment