My jQuery code is functioning properly, but I am aiming to have the child ul
close only when I specifically click on it; currently, it closes when I click on the parent li
as well. How can I make this adjustment to the behavior?
$(document).ready(function(){
$("ul>li").click(function(){
var lk=$(this).text();
var w=$("ul li:contains('"+lk+"')").width();
$("ul li").removeClass("h");
$("ul li:contains('"+lk+"')").addClass("h");
if(w>200){var a=1;$("ul li").removeClass("h");}else{var a=0;}
if(a==1){
$("ul li:contains('"+lk+"') ul").hide(function(){
$("ul li:contains('"+lk+"')").animate({width:"200px"},"fast");
});
}else{
$("ul li ul").hide();
$("ul>li").animate({width:"200px"},"fast");
$("ul li:contains('"+lk+"')").animate({width:"1200px"},"fast",function(){
$("ul li:contains('"+lk+"')>ul").slideDown();
});
}
});
});