简体   繁体   中英

Why does jQuery .height() not work in firefox?

When I console.log(titleHeight); I get 0 in firefox but the correct height in chrome.. Any idea why?

$('.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)`,
        });
    });
});

use this same code after: 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!');
});

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM