0
votes

i want to get scaled size of an image using javascript. for example: original size of a image is 600x600 and by using css i set it to width 100%

so if size of the browser window changes the height and width of the image will be scaled accordingly.

i want to get that scaled height and width of the image. using javascript.

1

1 Answers

1
votes

Using jQuery:

$("#myImage").height();
$("#myImage").width();

Plain Javascript:

document.getElementById("myImage").style.offsetHeight;
document.getElementById("myImage").style.offsetWidth;

I think offsetHeight and offsetWidth are appropriate here, feel free to correct me if otherwise.