For some reason $("...").width()
is returning the wrong value immediately after document ready.
I'm see these values:
Immediately after document ready:
$(document).ready(function(){
$("li.active a").width() //returns 76 - incorrect
});
$(document).ready(function(){
$(window).load(function(){
$("li.active a").width() //returns 59 - the correct value
});
});
$(document).ready(function(){
setTimeout(function(){
$("li.active a").width() //returns 59 - the correct value
}, 100);
});
I'm getting the width of wordpress menu items and resizing them so that they always fit in my responsive design. There are no images or assets that should cause this change.
Update
See my comment below. Turns out there was an asset, an embedded font, that took a split second to load.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…