【问题标题】:(jquery3.0 up): window.load v.s. document.ready and wrong operation on window.load(jquery3.0 以上):window.load vs. document.ready 和 window.load 上的错误操作
【发布时间】:2017-09-26 02:21:10
【问题描述】:

我已经通过网络搜索了几个网站。我仍然有问题:我选择window.load执行以下代码,但我的高度总是未定义。

<!DOCTYPE html> 
<html>
   <head>
      <title>Tobyliao</title>
      <script src="jquery-3.2.1.min.js" type="text/javascript"></script>
      <script type="text/javascript"> // $(window).on('load', function() { ... }); $(document).ready(function(){ // $('#div1').html('Height='+$('img1').height()+'Width='+$(img1‌​).width()); }); $(window).on("load", function(){ $('#div1').html('Height='+$('img1').height()+'<br/>'+'Wid‌​th='+$(img1).width()‌​); }); </script> 
      <div id="div1"></div>
      <img src="microsd.jpg" id="img1"> 
   </head>
   <body> </body>
</html>

【问题讨论】:

  • Tobyliao

标签: jquery html jquery-3


【解决方案1】:

查看JQuery API 文档,看起来他们的示例将语法显示为:

$( window ).load(function() {
  // Run code
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 2015-05-08
    • 1970-01-01
    • 2023-03-21
    • 2012-04-07
    相关资源
    最近更新 更多