0

I'm making chrome plugin. When page is loading, html has no element (for example with id "#var1"), this element will appear later on page.

Is it possible to set jquery checker?

My current solution:

$('body').bind('DOMNodeInserted', function(e) {
  if ($(e.target).attr("id") == "var1") {
    //My event here
  }
});

Is it possible to make my solution better and maybe like jquery code (event or function) with detecting classes and Ids by '.class' and '#id'?? (Current code detect only id)

Maybe something like:

$('body', '#var1').liveadding(function() {
  //My event here
});
SPnova
  • 489
  • 1
  • 6
  • 14
  • 1
    Try coding a listener, http://stackoverflow.com/questions/3219758/detect-changes-in-the-dom and then the callback function as you showed in the second code block. – Jepser Bernardino Nov 25 '13 at 03:26
  • But need way to quick detecting which element was added to dom. And do event only if needed element was added. But I see only way for detecting DOM changing onDomChange() @jepser – SPnova Nov 25 '13 at 03:45

0 Answers0