使用的tabindex和jQuery對焦點事件綁定比任何你想要的
$("li a").focus(function() {
$(this).parent().find('ul').slideDown(200); // example of targeting nested UL with slide down animation
});
它應該像這樣工作 然後用模糊的事件來隱藏子菜單觸發
$("li a").blur(function() {
// your code here to hide submenu
});
啓用點擊事件:
$("li a").click(function() {
// target all opened submenus and hide them by its class name
$("ul.active-submenu").slideUp(200).removeClass("active-submenu");
// adds class to submenu so you can determine easily which is active
$(this).parent().find('ul').slideToggle(200).toggleClass('active-submenu');
});
的李,這也將與點擊事件一起工作嗎? – hcharge 2012-08-15 13:29:39
不行,你需要綁定另一個點擊事件處理程序來做到這一點 – derki 2012-08-15 13:32:41
好吧,我想我開始明白,你知道我如何可以針對特定的點擊李的孩子ul嗎? – hcharge 2012-08-15 13:36:45