read img width set from css file - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Style

Description

read img width set from css file

Demo Code

ResultView the demo in separate window

<!doctype html>
<html>
   <head> 
      <style>

#slideshow img {//w  w w . j  a v a 2  s . co m
   display : block;
   border:1px solid;
   width : 300px;
   height : 200px;
}


      </style> 
   </head> 
   <body> 
      <div id="slideshow"> 
         <img src="slides/1.gif"> 
         <img src="slides/2.gif"> 
         <img src="slides/3.gif"> 
      </div> 
      <script>
       window.onload = function () {
           console.log(document.getElementsByTagName('img')[0].clientWidth);
       }
      
      </script>  
   </body>
</html>

Related Tutorials