I have multiple rows and with text box and button, I created a jQuery function to get the value of Text-box on class click. I tried so long but unable to get value. what I am doing wrong here.? Thanks in Advance. Text-box Code:-
$('input.R_Insert').click(function() {
var roundNum = 0; // row no get from db (1,2,3,4,5..)
var bb = "#TextBox" + roundNum;
var x = $("bb").val();
alert(x);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tbody>
<tr>
<td>
<div id="">
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" CssClass="form-control" Rows="5" Text="" Enabled="false"></asp:TextBox>
<asp:Button ID="btnSubmit1" runat="server" Text="Submit" CssClass="add_top_10 R_Insert" Enabled="false" />
</div>
</td>
<td>
<div id="">
<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" CssClass="form-control" Rows="5" Enabled="false"></asp:TextBox>
<asp:Button ID="btnSubmit2" runat="server" Text="Submit" CssClass="add_top_10 R_Insert" Enabled="false" />
</div>
</td>
</tr>
<tr>
<td>
<div id="">
<asp:TextBox ID="TextBox3" runat="server" TextMode="MultiLine" CssClass="form-control" Rows="5" Text="" Enabled="false"></asp:TextBox>
<asp:Button ID="btnSubmit3" runat="server" Text="Submit" CssClass="add_top_10 R_Insert" Enabled="false" />
</div>
</td>
<td>
<div id="">
<asp:TextBox ID="TextBox4" runat="server" TextMode="MultiLine" CssClass="form-control" Rows="5" Enabled="false"></asp:TextBox>
<asp:Button ID="btnSubmit4" runat="server" Text="Submit" CssClass="add_top_10 R_Insert" Enabled="false" />
</div>
</td>
</tr>
</tbody>
#Textbox0element exist in your HTML? If so, where is it? Also note the selector should be$(bb), not$('bb')- note the lack of quotes as you're providing a variable, not a string literal$('bb')also but failed.