$(this).height() is zero on mobile while on desktop it has its intended height

26 Views Asked by At

I've ran into a problem that the ($this) object's height is 0 on mobile while it has the height on desktop This problem only occurs on the first load of the site. After I reload it or i access the site via url, the object has the intended height!

Here's the code:

var maxLaenge = 0;
var minHoehe = 0;
$(this).find(".img").each(function() {
    var imgLaenge = $(this).width();
    if (imgLaenge > maxLaenge) {
        maxLaenge = imgLaenge;
        minHoehe = $(this).height();
        console.log($(this));
    }
});
0

There are 0 best solutions below