Trying to find the img height and apply inline as attr. Currently img only has src attr but want to dynamically find height and apply.
Current
<img src="#">
Desired
<img src="#" height="find this images height">
This is what i have so far
$(document).ready(function() {
$("img").load(function() {
var width = $(this).width();
var height = $(this).height() ;
$(this).attr( "height", "+ height" );
});
});
Any ideas?
From jQuery documentation :
You may use this :
In a cleaner way :