tags:

views:

25

answers:

2

I have a ul as follows: It can`t read the text values neither with val() nor text(). Can anyone help please

<ul id="mylist">     
<li id="1"><input type = "text" value= "aaaaa" /></li>     
<li id="2"><input type = "text" value= "bbbb" /></li>
<li id="3"><input type = "text" value= "ccc" /></li>
<li id="5"><input type = "text" value= "dddd" /></li>

</ul><button id="Button1">Add Another2</button>
var values = []; $(document).ready(function() { $("#Button1").click(function() { $( "#mylist li text").each(function() { alert($(this).text()); values.push($(this).text()); }); }); });
A: 

You must ":" in jquery selector

$("#mylist li :text")
allenwei
A: 

$(document).ready(function() { $("#Button1").click(function() {

            var i = 0;
            var inputs = new Array();
            $("#mylist li").find("input").each(function() {
            alert($(this).val());
            inputs[i] = $(this).val();
                i++;
            });

                });
            });