I am trying to add an image to the end of the page, grab it's height, and width, and use these values to calculate what the height/width of another image on the page will be (This is for an online equation editor I'm building).
I am setting the height with CSS, and would like the width to scale automatically for me. Do I need to do this in jquery, or will the browser do this automatically for me?
Here is an example of the type of thing I'm trying to do.
$( 'body' ).append( '<img class="letter" src="my_image.png">' );
var new_element_height = $('.letter').last().outerHeight();
var new_element_width = $('.letter').last().outerWidth();
$('.letter').last().remove();
alert( new_element_height );
alert( new_element_width );
My CSS is something like:
.letter {
height: 50px;
}
The new_element_height gives me 50px, new_element_width gives me 0px. I'm guessing this is because I'm dynamically loading these images and then trying to grab the height/width.
I would like the height to be 50px, and the width to scale correctly to that height, and then place those values in the new_element_height/new_element_width variables.