[Javascript] Setting Opacity with JavaScript

Hassan Schroeder hassan at webtuitive.com
Thu Jun 26 14:22:04 CDT 2003


Robert Wall wrote:

> I've got an image (img1.jpg, let's say).  I want to be able to change the
> transparency of the image (filter:Alpha CSS property) when the user clicks
> on a link.
> 
> I'm wondering what the syntax for changing the style attribute is, and any
> comments as to the best way of handling it would be appreciated.

For example, 50% --

IE:  .style.filter = "alpha(opacity=50)";
Moz: .style.MozOpacity = .5;

It'll just be `.style.opacity` in CSS3, should we live so long  :-)

HTH!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the Javascript mailing list