Javascript 使用DomainNodeInserted确定.class名称
如果我在下面运行此操作:Javascript 使用DomainNodeInserted确定.class名称,javascript,jquery,dom,mutation-events,Javascript,Jquery,Dom,Mutation Events,如果我在下面运行此操作: $(document).bind('DOMNodeInserted', function(){ $('.new', this).hide(); }); 它将正常运行,并将隐藏.new div。但我需要执行以下操作: $(document).bind('DOMNodeInserted', function(){ // if class .new exists // do something to the other
$(document).bind('DOMNodeInserted', function(){
$('.new', this).hide();
});
它将正常运行,并将隐藏.new div。但我需要执行以下操作:
$(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
});
非常感谢试试这个:
$(document).bind('DOMNodeInserted', function () {
if ($('.new').length) {
// if class .new exists
// do something to the other elements e.g (body, #div, h1, h2, etc) not to .new class
}
});
试试这个:
$(document).bind('DOMNodeInserted', function () {
if ($('.new').length) {
// if class .new exists
// do something to the other elements e.g (body, #div, h1, h2, etc) not to .new class
}
});
您只需检查
.new
的长度,并按如下方式进行处理:
$(document).bind('DOMNodeInserted', function(){
if($('.new').length > 0)
{
$('body *').not('.new').hide();
}
});
查看此您只需检查
.new
的长度,并按如下方式进行处理:
$(document).bind('DOMNodeInserted', function(){
if($('.new').length > 0)
{
$('body *').not('.new').hide();
}
});
看到这个了吗