$(window).load(函数()在一个语句中?

时间:2017-03-29 21:40:07

标签: javascript jquery

不确定我是否可以在语句中包含$(window).load(function()?这是正确的吗?

    else if (isAndroid){ 
      $('.apple, .bottomcta, .bottomapple, .cta, .cta2').hide(); 
      $('.android').show(); 


      $(window).load(function() { 

    if ($('.yes2, .YES2').css('display') == 'none') { 
      $('#bottombadge > p, #badge > p, .bottomandroid, .android, .bottomapple, .apple').remove(); 
      $('#button, .cta, .bottomcta').show(); 
      } 

    else if ($('.no, .NO').css('display') == 'block') { 
      $('.bottomapple, .apple').remove();
      }                                          

      }
      );

    }

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

是的,你可以做到。

毕竟,您只是使用jQuery将事件处理程序附加到Working directory created: /var/folders/rq/5mypbx554jgflr6c8097zltc0000gn/T/osm-bundler-CXSOEi BundlerMatching executable path: /Users/PeterE/Downloads/osm-bundler/software/bundler/bin/KeyMatchFull Sift executable path: /Users/PeterE/Downloads/osm-bundler/software/vlfeat/bin/glx/sift Processing photo 'IMG_0055.JPG': Entry for the camera 'Apple', 'iPod touch' does not exist in the camera database Can't estimate focal length in pixels for the photo '/Users/PeterE/Desktop/osmbundlertest/IMG_0055.JPG' Copy of the photo has been scaled down to 1200x896 Extracting features with the SIFT method from VLFeat library... 对象的load事件。

但是,它并没有那么有用,因为@Siphalor评论说:

  

代码永远不会被执行,因为页面应该已经完成   已加载

相反,你应该做类似的事情:

window