clientWidth
propertyYou can simply use the JavaScript clientWidth
property to get the current width and height of an image. This property will round the value to an integer.
Let's check out the following example to understand how it basically works:
<!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="sky.jpg" id="sky" width="250" alt="Cloudy Sky">
<p><button type="button" onclick="imgSize();">Get Current Image Size</button></p>
</body>
</html>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Laravel 8 Default Password Validation Rules
Password is the most important data in a...How to Export 10M+ records in XLSX in Laravel 7.x using rap2hpoutre/fast-excel
This post introduce FastExcel for Larave...How to Enable CORS in NGINX
CORS or Cross-Origin Resource Sharing is...VueJs Google Column Chart with Example
Today,I will learn you how to create Goo...This Cache Store does not Support Tagging in Laravel
In this article, I will share with you a...