Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Find Current Image Width and Height</title> <script> function imgSize(){ var myImg = document.querySelector("#sky"); var currWidth = myImg.clientWidth; var currHeight = myImg.clientHeight; alert("Current width=" + currWidth + ", " + "Original height=" + currHeight); } </script> </head> <body> <img src="/examples/images/sky.jpg" id="sky" width="250" alt="Cloudy Sky"> <p><button type="button" onclick="imgSize();">Get Current Image Size</button></p> </body> </html>