function getOriginalSize(el){ var element = document.getElementById(el); //element.naturalWidth alert('Width of '+el+' is : '+element.naturalWidth); //element.naturalHeight alert('Height of '+el+' is : '+element.naturalHeight); }
<p><i><b>Click on the Image to get naturalWidth and naturalHeight</b></i></p> <p>Original Size of an Image is 350 x 225 px.</p> <img id="img1" src="http://canindia.com/wp-content/uploads/2013/02/12/sushil-kumar.jpg" onclick="getOriginalSize(this.id)"> <p> Here we are going to change image's width="200px" and height = "150px"</p> <img id="img2" src="http://canindia.com/wp-content/uploads/2013/02/12/sushil-kumar.jpg" width="200px" height="150px" onclick="getOriginalSize(this.id)">