2 に答える
1
次のように、各レベルのクリックを選択して処理できます。
// first level links
$("ul#menu > li > a").click(function() {
e.preventDefault();
// show sub-menu etc..
}
// second level links (remove this block if you dont want any spl processing here)
$("ul#menu > li > ul > li > a").click(function() {
return true; // behave like normal links
});
于 2012-11-06T13:30:23.177 に答える
0
クリックしたものli
がそのul
中にネストされているかどうかを確認することで、これを実現できます。
$('#menu li').click(function(e) {
$this = $(this);
e.stopPropagation();
if ($this.has('ul').length) {
e.preventDefault();
$('ul', this).fadeToggle();
}
});
于 2012-11-06T13:50:09.043 に答える