2014. szeptember 12., péntek

jQuery - Refresh a div content

If you would like to refresh the content of div_2 when the content of div_1 is changed you can use the following:

jQuery(window).load(function(){
        initialize();
});


rDisplay = function(){
    var lDivId = "div_2";
    jQuery('#' + lDivId).load(location.href+' #' + lDivId);
}


initialize = function(){  
    var div = document.getElementById ("div_1");
    if (div.addEventListener) {
        div.addEventListener ('DOMSubtreeModified', rDisplay, false);
    }
}


You can find more details here.
It's worth to read.

Nincsenek megjegyzések:

Megjegyzés küldése