为什么jQuery .width返回0而不是1

时间:2013-07-10 02:22:00

标签: javascript jquery

为什么jQuery .width返回0而不是1.我正在从第三方加载图像,需要一段时间才能加载。如何首先加载图像然后抓取图像宽度?

     $(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();
    });
 });

0 个答案:

没有答案
相关问题