If i run this below:
$(document).bind('DOMNodeInserted', function(){
$('.new', this).hide();
});
it will run ok and it will hide the .new div. But i need to do something like the below:
$(document).bind('DOMNodeInserted', function(){
// if class .new exists
// do something to the other elements e.g (body, #div, h1, h2, etc) not to .new class
});
many thanks
You can just check the length of .new
, and handle it as follows:
$(document).bind('DOMNodeInserted', function(){
if($('.new').length > 0)
{
$('body *').not('.new').hide();
}
});
See this jsFiddle Demo