jQuery count non-empty fields
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
精彩评论