Created
May 1, 2013 03:16
-
-
Save brendanfalkowski/5493549 to your computer and use it in GitHub Desktop.
jQuery snippet to monitor an element for an element to appear in the DOM, then duplicate its contents into another element.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cachedContentHtml = ''; | |
window.setInterval(function() { | |
var watchElem = $('.watch-me'); | |
// Check if "element" exists in DOM yet | |
if ( watchElem.length ) { | |
// Grab the content we need | |
var contentHtml = $('.content').html(); | |
// If content has changed, then update another element | |
if ( cachedContentHtml != contentHtml ) { | |
// Save a new cached html value | |
cachedContentHtml = contentHtml; | |
// Update the duplicate element | |
$('.duplicate-elem').html( contentHtml ); | |
} | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment