Why jQuery .width is returning 0 instead of 1. I am loading image from 3rd party and it take a while to load. how can I load image first and then grab the image width?
$(document).ready(function(){
$("#dealerChatSmallButtonHeader a img").one('load', function() {
var chatButtonWidth = $('#dealerChatSmallButtonHeader a img');
console.log(chatButtonWidth.width());
if(chatButtonWidth.width() != 0)
{
$('#dealerChatSmallHeader').css('display','inline');
$('#dealerChatSmallBody').css('display','inline');
$('#dealerChatLarge').css('display','block');
}
}).each(function() {
if(this.complete) $(this).load();
});
});