My button and table is as shown,
<button type="button" class="btn btn-md" id="addRowBtn">Test Button To Add Row</button>
<table id="tableForRows">
<tr>
<td>
</td>
</tr>
</table>
I want to keep adding text boxes on click of button..My jquery is as shown,
$(document).ready(function () {
$("#addRowBtn").on("click", function () {
var tableRow = $("#tableForRows").html();
var itemToAdd = "<tr><td><input type="text"/></td></tr>";
$("#tableForRows").append(itemToAdd);
});
});
Help me know what the right way is..Thanks in advance..
You have quotation problem, use single quotes for type='text'
:
"<tr><td><input type='text'/></td></tr>";
Also, based on what you shared, var tableRow = $("#tableForRows").html();
is redundant.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments