What the jQuery function need to add?
Good day! Help me please with the following question:
We have HTML structure
<ul>
<li><a href="#">Link</a></li>
<li><a href="#">Submenu</a>
<ul>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>开发者_JAVA百科
</li>
<li><a href="#">Submenu</a></li>
</ul>
and JS jQuery code
$(document).ready(function(){
$(".cat-menu ul li ul").hide();
$(".cat-menu ul li ul li ul").hide();
$('.cat-menu span').click(function() {
$(this).next().slideToggle('fast');
return false;
}).next().hide();
$('.cat-menu ul li ul li ul li:last').toggleClass("last");
});
Tell me what to do to the script did not block these links, and processed by the event click only those links in which LI has a submenu?
there is the jquery function HAS
I'm not entirely sure what you want to accomplish. Would it be possible to extend your question or clarify, perhaps by adding a bit more of the outer HTML code?
I'm assuming you're trying to create a menu with submenus that will show when the menu item is clicked. Using your HTML structure, this is how I will do it:
$(document).ready(function(){
$("ul#menu li > a").click(function() {
$(this).parent("li").children("ul").slideDown("fast");
$(this).parent("li").siblings("li").children("ul").slideUp("fast");
});
$("ul#menu ul").hide();
});
精彩评论