javascript - How to see if inner UL is expanded or collapsed -
<li class="setrelative"> <a class="tflink clickme current" data-toggle=".tflink1" id="current" href="javascript:void(0);"><img src="theimages/imgplus.png" id="imgfirstm" class="imgexpcol">header 1</a> <ul class="uspstyle uspinner" style="width: 80%;"> <li><a class="tflink clickme" title="sub-page" data-toggle=".tf1slink1" href="javascript:void(0);">sub-page</a></li> <li><a class="tflink clickme" title="test" data-toggle=".tf2slink1" href="javascript:void(0);">test</a></li> </ul> </li>
by default uspinner
class unordered list
not displayed , expanded when clickme
link clicked:
$('.clickme').click(function () { var $this = $(this); $this.closest("li").find("ul").slidetoggle(); $('.clickme').removeclass('current'); $this.addclass('current'); });
how can add above script see, if inner ul
expanded or collapsed.
tried didn't work:
var item = $this.closest("li").find("ul").is(":hidden"); alert(item); if (item) { console.log("no item"); } else { console.log("item"); }
try using $(this).parent().find("ul").eq(0).is(':visible');
parent of anchor link you're clicking on, finding first child ul , checking if it's displayed on screen or not. should give correct feedback.
Comments
Post a Comment