Is there an event in JQuery, Javascript, or the DOM in general that I can subscribe to that will notify me when an element become visible or invisible (display:none)?
Asked
Active
Viewed 1.1k times
14
-
possible duplicate of [onHide() type event in jQuery](http://stackoverflow.com/questions/2857900/onhide-type-event-in-jquery) – Liam Feb 04 '14 at 10:19
1 Answers
30
There are events for DOMAttrModified and onpropertychange (IE) that can track DOM element changes and fire an event.
Wrote about this with a jQuery plug-in that allows monitoring changes to CSS styles here:
http://www.west-wind.com/weblog/posts/478985.aspx
This might be just what you need as you could do something like:
$("#myControl").watch("display,visibility", function() { showStatus("changed...") });

Rick Strahl
- 17,302
- 14
- 89
- 134
-
2Use this inside anonymous function to see if item is visible or not: $(this).is(':visible'); – Janis Veinbergs Mar 03 '11 at 12:48
-