Skip to content

Instantly share code, notes, and snippets.

@jaydson
Created November 11, 2011 18:36
Show Gist options
  • Select an option

  • Save jaydson/1358813 to your computer and use it in GitHub Desktop.

Select an option

Save jaydson/1358813 to your computer and use it in GitHub Desktop.
How to observe when an element is created
var readyElement = (function(){
return {
observe : function(id,callback){
var interval = setInterval(function(){
if(document.getElementById(id)){
callback(document.getElementById(id));
clearInterval(interval);
}
},60);
}
}
})();
readyElement.observe('my_awesome_new_element',function(el){ console.log(el) });
@jaydson
Copy link
Author

jaydson commented Nov 11, 2011

Cool, sounds like a good micro-solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment