0
$(window).bind("load", function() {
   $("#placeholder .flot-text .xAxis .tickLabel").css('height','90px','important');
});

嗨,我如何在页面加载后立即执行此功能?仅当我刷新页面时才调用此函数,但我希望在加载页面时调用它。

4

5 回答 5

5

像这样使用document.ready

$(document).ready(function(){     
    $("#placeholder .flot-text .xAxis .tickLabel").css('height','90px','important');
});

或者您可以使用$(function)之类的

$(function(){
    $("#placeholder .flot-text .xAxis .tickLabel").css('height','90px','important'); 
});
于 2013-05-31T05:37:36.847 回答
2
$(document).ready(function(){
   //execute ur code here.
});
于 2013-05-31T05:38:34.773 回答
1

试试下面的代码

$(document).ready(function() {
  // Handler for .ready() called.
  $("#placeholder .flot-text .xAxis .tickLabel").css('height','90px','important');
});

或者

$(function() {
     // Handler for .ready() called.
     $("#placeholder .flot-text .xAxis .tickLabel").css('height','90px','important');
    });

.ready() - 指定在 DOM 完全加载时执行的函数。

jQuery Document Ready 解释

于 2013-05-31T05:38:10.373 回答
1

使用你可以使用的 jQuery;

$(function(){
//Your code here
});
于 2013-05-31T05:38:27.390 回答
0
$(document).ready(function(){
   //Write your code 
});

将脚本放在底部

脚本引起的问题是它们会阻止并行下载。HTTP/1.1 规范建议浏览器每个主机名并行下载不超过两个组件。如果您从多个主机名提供图像,则可以同时进行两次以上的下载。但是,在下载脚本时,浏览器不会启动任何其他下载,即使在不同的主机名上也是如此。在某些情况下,将脚本移到底部并不容易。例如,如果脚本使用 document.write 插入部分页面内容,则不能将其移至页面下方。也可能存在范围问题。在许多情况下,有一些方法可以解决这些情况。经常出现的另一种建议是使用延迟脚本。DEFER 属性表示该脚本不包含 document.write,并且是浏览器可以继续呈现的线索。不幸的是,Firefox 不支持 DEFER 属性。在 Internet Explorer 中,脚本可能会被延迟,但不会像期望的那样延迟。如果可以推迟脚本,也可以将其移至页面底部。这将使您的网页加载速度更快。

http://developer.yahoo.com/performance/rules.html#js_bottom

于 2013-05-31T05:39:03.150 回答