instance method Element#setOpacity

View source on GitHub →

Element#setOpacity(opacity) → [Element…]

Sets the visual opacity of an element while working around inconsistencies in various browsers. The opacity argument should be a floating point number, where the value of 0 is fully transparent and 1 is fully opaque.

Element.setStyle method uses Element.setOpacity internally when needed.

var element = $('myelement');
// set to 50% transparency
 // these are equivalent, but allow for setting more than
// one CSS property at once:
element.setStyle({ opacity: 0.5 });
element.setStyle("opacity: 0.5");

This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.