dynamically change image opacity in Javascript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

dynamically change image opacity in Javascript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from www  .jav  a  2 s.c om*/
img = document.getElementById("test");
img.style.filter       = "alpha(opacity=75)";
img.style.MozOpacity   = "0.75";
img.style.opacity      = "0.75";
img.style.KhtmlOpacity = "0.75";
    }

      </script> 
   </head> 
   <body> 
      <img id="test" src="http://photos.smugmug.com/photos/344291068_HdnTo-S.jpg">  
   </body>
</html>

Related Tutorials