I am creating add and delete rows dynamically but it seems that my code is not working properly please help me. As i'm unable to get alert as i m trying to append table rows but before that it will check wheather table exist or not than add row
$(document).ready(function()
{
$("#add_Row").click(function()
{
if($(".test").html() == null)
{
alert("empty");
$("#add_Row").click(function()
{
alert("I am here");
$('.test').append(
"<tr><td><input type="text" class="index_txtBox"/></td>
<td><input type="checkbox" class="check_box"/></td>
<td><input type="text" class="txt_Box"/></td>
<td><select><option></option></select></td></tr>
");
});
$("#delete_Row").click(function()
{
if($(".test tr").length != 0)
{
$(".test tr:last-child").remove();
}
else
{
alert("Now table is empty");
}
}
}
});
});
</script>
</head>
<body>
<div class="buttons">
<input type="button" id="add_Row" value="Add Row" />
<input type="button" id="delete_Row" value="Delete Row" />
<input type="checkbox" id="select_All" value="Select All" />Select All
</div>
class testis missing in the code provided pls include all relevant code to the OP