My code is supposed to get the height of several items in a div. It works like a charm in Firefox, but in WebKit the is no height().
for (var i = 0; i < items.length; i++) {
var item = items[i];
var itemHeight;
var itemWidth;
var imageItem = $($(item).find('.teaser_image'));
itemWidth = imageItem.width();
if (itemWidth > this.imageWidth()) {
imageItem.width(this.imageWidth());
}
// TODO: Height-thingy works in Firefox but not in WebKit.
itemHeight = imageItem.height();
}
The strange thing is that the imageItem
object is correct in WebKit and Firefox. But if I use .height()
on it, it is 0 in WebKit. The used jQuery Version is 1.7.2 and can not be changed.
This works for me http://jsfiddle.net/z6bYp/1/
<script>
var imageItem = $('.teaser_image');
alert(imageItem.height());
</script>
Be sure to find something when you define imageItem, use the debugger
for (var i = 0; i < items.length; i++) {
var imageItem = $($(item).find('.teaser_image'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.