Adam Ritenauer
Adam Ritenauer

Reputation: 3181

JQuery/Javascript/DOM Visibility Event

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)?

Upvotes: 14

Views: 11336

Answers (1)

Rick Strahl
Rick Strahl

Reputation: 17671

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...") });

Upvotes: 30

Related Questions