0

I have the following img tag:

   <img id="product-image" src="http://cf.test.com/images/store_logos/thumbnail/43f1ee4d5fe422e9440ab4afe065bbff899b24b0.jpg" width="228" height="304" style="opacity: 1;">

Trying to extract out the 304 height value:

$('#product-image').height();

However it always gives me the actual size of the image. Any ideas?

adit
  • 32,574
  • 72
  • 229
  • 373

6 Answers6

2

Try this

$(document).ready(function(){
    alert("Width :"+$('#product-image').width());
});
Nitesh Singh Rajput
  • 607
  • 1
  • 7
  • 24
1

Use this

$('#product-image').attr("height");
TGH
  • 38,769
  • 12
  • 102
  • 135
0

$('#product-image').prop("height");

Pankucins
  • 1,690
  • 1
  • 16
  • 25
0

Try to get the height after the image rendered:

$(document).ready(function() {
    $('#product-image').load(function() {
        alert($(this).height());
        alert($(this).width());
    });
});
blake305
  • 2,196
  • 3
  • 23
  • 52
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
0

If your using JQuery before 1.6 means

$('#product-image').attr("height")

other wise

$('#product-image').prop("height")

Will give you answer

Thirumalai murugan
  • 5,698
  • 8
  • 32
  • 54
-3

put the image in the div and take the size of div