How do I count list elements that are not hidden?
Posted
by Baloneysammitch
on Stack Overflow
See other posts from Stack Overflow
or by Baloneysammitch
Published on 2010-04-05T23:55:39Z
Indexed on
2010/04/06
0:03 UTC
Read the original article
Hit count: 115
Starting with a simple list:
<ul>
<li>Item 1</li>
<li style="display: none;">Item 2</li>
<li>Item 3</li>
</ul>
I know that I can subtract the hidden elements from the list total
$('ul li').size() - $('ul li:hidden').size()
But I thought there might be a more elegant way to achieve this with jquery:
$('ul li:hidden:not').size()
That doesn't work. Any ideas?
© Stack Overflow or respective owner