tags:

views:

32

answers:

2

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?

+4  A: 

It's as simple as this:

var values = [];

$('#ul1 li textarea').each(function() {
    values.push($(this).val());
});
Tatu Ulmanen
+3  A: 

Should be enough

 var values = $( "#ul1 textarea").map( function( )
 { 
       return $(this).val( );
 }).get( );
Artem Barger