-6

I need to get number of li element inside a ul. in fact i want to perform specific action when a ul has no child. is there any way to do that with jquery?

hamed
  • 7,681
  • 13
  • 50
  • 104

1 Answers1

0

You can use .has() selector:

if(!$('ul').has('li')){//ul is empty

}
Milind Anantwar
  • 79,642
  • 23
  • 92
  • 120