3

Can someone tell me how to hide a <ul> when I only have one child <li> in it?

I have this code but it's not working.

$(document).ready(function() {
 $("#flex-slider-carousel ul li").length();
  if($('#flex-slider-carousel ul li').length == 1){
 $("#flex-slider-carousel ul li").hide();}
});

Thanks!

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Mel
  • 33
  • 3

1 Answers1

2

length is a property not a method. You can use the filter method:

$("#flex-slider-carousel ul").filter(function() {
   return $(this).children().length === 1;
}).hide();
Ram
  • 143,282
  • 16
  • 168
  • 197