-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,939
  • 15
  • 60
  • 114

1 Answers1

0

You can use .has() selector:

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

}
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125