Alex Rivera | Logout

jQuery event - element become visible

Asked 2012-05-14T13:15:51.197
14

Possible Duplicate:
jQuery event to trigger action when a div is made visible

How can I run some my code when element, wich was loaded by ajax, become visible("display" is switching from "none" to "block")? Well, I need some event like

$('#element').live('show', function(){
// CODE
});

Or event that watching for deleting/adding some class to element

Edit
Report

2 Answers

2

There's nothing built-in jQuery that allows you to achieve that. You may take a look at the livequery plugin. For example:

$('#element').livequery(function() {
    // CODE
});

When an element with id="element" is added to the DOM the callback should be executed.

answered 2012-05-14T13:20:23.210
0

Have you tried jQuery.load()?

http://api.jquery.com/load-event/

It should work at least for images, script tags, etc... not for elements that don't have a URL, though.

Otherwise, livequery should be of help:

jquery live event for added dom elements

answered 2012-05-14T13:17:33.863

Your Answer