I have dynamically generated as given below.I need to get the value of text box by clicking on the updateCart button in each row.

 @foreach (var item in Session["Cart"] as List<AP.WebApp.Models.Cart>)
                    <tr class="eachitem">
                        <td><img src="@item.Path.Split('~')[1]" style="width:200px;height:auto" /><p>@item.Title</p></td>
                        @if(item.Preview == 1){

                            @Html.CheckBox("preview", new { @checked = "checked" })
                        <td id="qtyid">
                            <input id="qty" type="text"  value="1"/></td>
                            <input id="deleteCart" type="submit" value="Delete" data-assigned-id="@item.ID" /></td>
                            <input id="updateCart" type="submit" value="Update" data-assigned-id="@item.ID"  /></td>


For that I tried :

 $('.cartItem').on('click', '#updateCart', function (e) {
var val = $(this).closest('#qtyid').find('#qty').val();

But alert(val) results undefined.Any idea please share.

Related posts

Recent Viewed