开发者

jQuery count non-empty fields

开发者 https://www.devze.com 2023-03-10 06:47 出处:网络
Trying to count the number of input fields of class \'.booked\' that are NOT empty (ie开发者_如何学C they have some kind of value entered.

Trying to count the number of input fields of class '.booked' that are NOT empty (ie开发者_如何学C they have some kind of value entered.

For some reason this is not doing it for me. Someone please put me out of my misery :)

$('input.booked:not(:empty)').length


Try this:

$('input.booked[value!=""]').length

empty returns nodes with no children, which isn't what you want.


the :empty selector filters to elements that have no child nodes. What you want is an attribute equals selector...

$("input.booked:not([value=''])").length
0

精彩评论

暂无评论...
验证码 换一张
取 消