[英]Why does jQuery .height() not work in firefox?
当我 console.log(titleHeight); 我在 Firefox 中得到 0,但在 chrome 中得到正确的高度.. 知道为什么吗?
$('.projects__col').each(function() {
const _this = $(this);
let titleHeight = title.height();
console.log(titleHeight); // gives me the correct height in Chrome but 0 in firefox
_this.click(function () {
_this.css({
'transform': `translateY(-${titleHeight}px)`,
'-o-transform': `translateY(-${titleHeight}px)`,
'-moz-transform': `translateY(-${titleHeight}px)`,
'-webkit-transform': `translateY(-${titleHeight}px)`,
});
});
});
在之后使用相同的代码: const _this = $(this);
$(this)
.load(function() {
//$('#result1').text('Image is loaded!');
let titleHeight = title.height();
console.log(titleHeight);
})
.error(function() {
$('#result1').text('Image is not loaded!');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.