Read text fields in jQuery
I have this answer in my Chrome console to view:
$('.checklist-17012').length
5
There are five in the view, so it is correct. The problem is they are all empty, and no matter what I do, I cannot count as empty:
$('.checklist-17012[val=""]').length
0
$('.pdf-checklist-17012[val=null]').length
0
Here's the HTML:
<input type="text" name="30954" id="30954" value="" class="checklist-17012 form-control">
What am I doing wrong?
+3
source to share
1 answer
There is no attribute val
. Should bevalue
$('.checklist-17012[value=""]').length
console.log($('.checklist-17012[value=""]').length)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="30954" id="30954" value="" class="checklist-17012 form-control">
+4
source to share