Jquery onChange event for Div
I have a page with the following two divs:
<div id="searchResults">
</div>
<div class="postSearchOptions" style="display: none;">
</div>
Is there a way that I can make the "postSearchOptions" div where the "searchResults" div is updated on the AJAX call? I have no control over the AJAX calls and I want to detect any changes in the "searchResults" div.
I tried to write the following JQuery code, but then realized that it requires JQuery 1.4 and I only have 1.3:
$("#searchResults").live("change", function() {
$(".postSearchOptions").css("display", "inline");
});
Is there a way to catch the search resolution change event using standard JavaScript or JQuery 1.3? Thanks!
a source to share
If the AJAX calls are made with jQuery, you can call the global event handler ajaxComplete
and run your code there.
a source to share
You can use setInterval to look, but as others have said it would be better to detect the change in the ajax callback. Here's a sketch of what the plugin will look like a "look" node, as you are trying to do with a live one:
jQuery.fn.watch = function() {
this.each(function() {
var original = $(this).html();
setInterval(function() {
var newHtml = $(this).html();
if (newHtml != original) {
$(this).trigger('change');
original = newHtml;
}
}, 500);
} );
}
a source to share