In the following code,after removing the checkboxes and adding it again.The alert always becomes true for "could not find checkboxes"
<div id="r_n">
<div name="r_t"><input type="checkbox" name="r_name" />Name</div>
<div name="r_t"><input type="checkbox" name="r_name" />Address</div>
<div name="r_t"><input type="checkbox" name="r_name" />Value</div>
<div name="r_t"><input type="checkbox" name="r_name" />Total</div>
</div>
<script>
$("r_t").remove();
$("r_n").html('');
Now all the checkboxes are removed form the dom
$("r_n").append('<div name="r_t"><input type="checkbox" name="r_name" />Name</div>
<div name="r_t"><input type="checkbox" name="r_name" />Address</div>
<div name="r_t"><input type="checkbox" name="r_name" />Value</div>
<div name="r_t"><input type="checkbox" name="r_name" />Total</div>');
if($("r_n :checkbox").length > 0) {
{
alert("Could not find checkboxes")
}
else
{
alert("Found");
}