Reputation: 155
I have a ul with id ul1. In the UL I have 3 li, each containing a textbox. How do I read each and every li of the ul to retrieve the values of the textbox in the li and put them in an array?
Upvotes: 2
Views: 1891
Reputation: 41222
Should be enough
var values = $( "#ul1 textarea").map( function( )
{
return $(this).val( );
}).get( );
Upvotes: 4
Reputation: 124768
It's as simple as this:
var values = [];
$('#ul1 li textarea').each(function() {
values.push($(this).val());
});
Upvotes: 5