调用(document).resize和(document).ready [英] Calling a (document).resize and (document).ready
本文介绍了调用(document).resize和(document).ready的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用$(document).ready
调用等高函数,尽管我必须这样调用它,因为我遇到类型错误.
I'm trying to call an equal height function using $(document).ready
, though I had to call it like this, because I was getting a Type Error.
jQuery(function($) {
$(".cols").equalHeights();
});
代替
$(document).ready(function() {
$(".cols").equalHeights();
});
这很好用,但是我也希望插件在页面调整大小时运行(以便它可以根据内容溢出进行调整).以下是调整大小的调用,如何将其与文档就绪调用结合在一起?
This works great, but I would also like the plugin to run when the page is resized, (so it will adjust to the content overflow). Below is the resize call, how can I combine it with the document ready call?
$(".cols").resize(function(){
$(".cols").equalHeights();
});
推荐答案
怎么样:
(function($) {
$(document).ready(function() {
var cols = $(".cols");
cols.resize(function(){
cols.equalHeights();
});
cols.trigger('resize');
});
})(jQuery);
这篇关于调用(document).resize和(document).ready的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文