简体   繁体   English

jQuery div高度更改事件

[英]JQuery div height changed event

I'm making a website at http://harrisonprograms.com . 我正在建立一个网站, 网址http://harrisonprograms.com

The design side of it is different to most sites, it also uses php and ajax to dynamically and asynchronously add comments, blog posts etc. 它的设计方面与大多数网站不同,它还使用php和ajax动态和异步地添加评论,博客文章等。

I use javascript to position the footer at the bottom of the page so when the page div extends it moves the footer further down the page by using the setTimeout function. 我使用javascript将页脚定位在页面底部,因此当页面div扩展时,它会通过使用setTimeout函数将页脚进一步向下移动。 However, this causes graphical glitches when scrolling up and down the page and if I set the time lower the footer lags. 但是,这会导致在上下滚动页面时出现图形故障,并且如果我将时间设置得较低,则页脚滞后会变小。

So I want to know if there is any possible way I can monitor when the div has been resized to activate this function without using setTimeout to prevent these graphical glitches. 所以我想知道是否有什么方法可以监视div的大小,以激活此功能,而无需使用setTimeout来防止这些图形故障。

Yes, you can use jQuery's resize event. 是的,您可以使用jQuery的resize事件。

$(window).resize(function() {
  // resize your div here
});

感谢所有人的所有帮助,但我发现一个可以满足我的需要的库,本·阿尔曼(Ben Alman)没有图形错误,如果有人需要此http://benalman.com/projects/jquery-resize-plugin/的帮助,请在此处查看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM