在窗口加载时调用文档就绪功能?

时间:2011-08-02 16:45:58

标签: javascript jquery

快速的......

如何在文档准备好的窗口加载中运行函数?

$(document).ready(function() {
   //How do I run this, down from Load??
   function thisFunction() {
      alert("This function");
   }
});

$(window).load(function() {
   thisFunction();
});

2 个答案:

答案 0 :(得分:1)

$(document).ready(function() {
   //How do I run this, down from Load??
   function thisFunction() {
      alert("This function");
   }
   $(window).load(thisFunction);
});

答案 1 :(得分:1)

$(document).ready(function() {
   //How do I run this, down from Load??
   window.thisFunction = function() {
      alert("This function");
   }
});

$(window).load(function() {
   thisFunction();
});

这样可行。