Reputation:
I have page with 3 textbox. I to find all textboxes which have value into it and print its text. How to do?
Upvotes: 0
Views: 136
Reputation: 36832
I gess that you need either
$("input[type=text]").val();
or
$("textarea").val();
Most likely, you will need both, so
$("input[type=text][value!=] textarea[value!=]").val();
would search the contents of all non empty elements on your page a user can insert text into.
Upvotes: 1
Reputation: 497
Use selector/text and selectors/attributeNotEqual.
$("form input:text[value!=]").each(function() {
$(this).val();
});
Upvotes: 0
Reputation: 3566
This is the code to fetch all the values of the in a page which are not empty:
$('input[type=text][value!=]').each( function() {
var value = $(this).val();
// do whatever you want with the value
});
Upvotes: 3