检查元素位置更改时的jQuery事件 [英] jQuery event to detect when element position changes
问题描述
我想知道是否有一个jQuery事件,我可以使用它来确定特定DIV的顶部
属性是否已更改。
I would like to know if there is a jQuery event that I can use to determine when a particular DIV's top
property has changed.
例如,我在DIV之上有隐形内容。当该内容变得可见时,DIV向下移动。我想捕获该事件,然后使用 offset()
函数获取X / Y坐标。
For instance, I have invisible content above a DIV. When that content becomes visible, the DIV is shifted down. I would like to capture that event and then use the offset()
function to get the X/Y coordinates.
推荐答案
容易的答案是,DOM中没有任何事件来检测布局更新。
The easy answer is that there are no events in the DOM for detecting layout updates.
你有几个选项我看到:
-
投票,讨厌,但可能会根据您的更新频率要求而工作。
Poll, nasty but it may work depending on your update frequency requirements.
点击任何事件导致隐形DIV改变大小,并做任何你需要做的处理程序。
Tap into whatever event causes the invisible DIV to change size and do whatever you need to do in that handler
我会纠正自己。
I shall correct myself.
我看了一下DOM,注意到DOMAttrModified事件,并发现您可能能够 JQuery插件要实现你想要的。
I took a look at the DOM and noticed the DOMAttrModified event and found this JQuery Plug-In that you might be able to leverage to do what you want.
正如文章所提到的,它在IE和Firefox中很好,但在WebKit中似乎有问题。
As the article mentions, it works great in IE and Firefox but seems to have problems in WebKit.
这篇关于检查元素位置更改时的jQuery事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!