使用的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