Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  37] [ 1]  / answers: 1 / hits: 32707  / 12 Years ago, tue, march 27, 2012, 12:00:00

How can I use JavaScript to determine if a UL contains 1 or more LI's within?



Pseudo code



if('ul#items' has >= 1 LI){


Thanks,


More From » jquery

 Answers
30

With jQuery:



$('ul#items li').length >= 1


Without jQuery:



document.getElementById('items').getElementsByTagName('li').length >= 1

[#86576] Monday, March 26, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hailey

Total Points: 355
Total Questions: 91
Total Answers: 91

Location: India
Member since Wed, Aug 4, 2021
3 Years ago
;