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?
Asked
Active
Viewed 160 times
-6

hamed
- 7,939
- 15
- 60
- 114
-
2Yes there is. What have you tried – PW Kad Jan 06 '15 at 06:57
1 Answers
0
You can use .has()
selector:
if(!$('ul').has('li')){//ul is empty
}

Milind Anantwar
- 81,290
- 25
- 94
- 125
-
-
-
1@PWKad: i understand. but should not the question be downvoted rather than answer. – Milind Anantwar Jan 06 '15 at 07:01
-
I downvoted them all. It's a poor question that is a duplicate and a poor answerer who chooses to give a half-way answer rather than flag a duplicate. – PW Kad Jan 06 '15 at 07:06