当我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!');
});