For dynamically loaded content.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | jQuery(document).ready(function($) { //write function here function handleCanvas(canvas) { //do stuff here (like call function) } // set up the mutation observer var observer = new MutationObserver(function(mutations, me) { // `mutations` is an array of mutations that occurred // `me` is the MutationObserver instance var canvas = jQuery(".nivo-caption").length; if (canvas) { handleCanvas(canvas); me.disconnect(); // stop observing return; } }); // start observing observer.observe(document, { childList: true, subtree: true }); }); |