jQuery做出选择

tkt*_*986 1 javascript jquery

我有一个像这样的嵌套div

<div id="one">
    <div id="two">
        id two goes here
    </div>
    <div id="three">
           id three goes here
    </div>
    <div id="four">
          id four goes here
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

现在我想处理除div#four之外的所有div上的click和doubleclick事件,就像这样

$('#one').live('dblclick', function() {
                    my javascript code goes here
                });
('#one').live('click', function() {
                    my javascript code goes here
                });
Run Code Online (Sandbox Code Playgroud)

我如何使用上面的脚本并排除最后一个嵌套的div #four.

谢谢

小智 5

像这样:

$('#one, #one > div').not('#four').delegate('dblclick, click', function(){
  // my javascript code goes here
});
Run Code Online (Sandbox Code Playgroud)