0

これを以下で実行すると:

$(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
});

どうもありがとう

4

2 に答える 2

3

の長さを確認するだけで.new、次のように処理できます。

$(document).bind('DOMNodeInserted', function(){
    if($('.new').length > 0)
    {
        $('body *').not('.new').hide();
    }
});

このjsFiddleデモを参照してください

于 2013-07-23T10:38:13.557 に答える
2

これを試して:

$(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
    }
});
于 2013-07-23T10:37:31.363 に答える