display css value for width and height display dynamically , Jquery Javascript alert function
<tr><td><img src="images/C003.jpg" alt="title" class="OrignialImage" /></td&g开发者_如何学Ct;</tr>
.OrignialImage
{
width:150px;
height:150px;
}
By using jquery, could we get width value from css class dynamically ? Is there any way to get width value and height value dynamically, Please let me know it.
u can check from here http://jsfiddle.net/ZsTAt/
$('.OrignialImage').css('height')
$('.OrignialImage').css('width')
$('.OrignialImage').height()
$('.OrignialImage').width()
You can use following jquery apis:
- width
- height
- css
Example:
$(".OrignialImage").width();
$(".OrignialImage").height();
jQuery has multiple ways to get the css height and width of an object. The simplest is $(<selector>).height()
and $(<selector>).width()
If you want the height and width with the padding included then you can use $(<selector>).innerHeight()
and $(<selector>).innerWidth()
respectively.
And if you want the height and width with the padding and margin included then you can use $(<selector>).outerHeight()
and $(<selector>).outerWidth()
And if you really wanted to you could use $(<selector>).css('height')
or $(<selector>).css('width')
For more information on these methods you can look at the jQuery documentation here http://api.jquery.com/category/dimensions/
精彩评论