调整窗口大小时调用函数 [英] Call a function when window is resized
本文介绍了调整窗口大小时调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每当调整浏览器窗口大小时,如何调用此(或任何)JS函数?
How can I call for this(or any) JS function to be run again whenever the Browser window is resized?
<script type="text/javascript">
function setEqualHeight(e) {
var t = 0;
e.each(function () {
currentHeight = $(this).height();
if (currentHeight > t) {
t = currentHeight
}
});
e.height(t)
}
$(document).ready(function () {
setEqualHeight($(".border"))
})
</script>
推荐答案
您可以使用窗口 onresize
事件:
window.onresize = setEqualHeight;
这篇关于调整窗口大小时调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文