looping through new div as they are created
- by eknown
I have a div, let's call it class="phoneNo". Inside the div there are two links, one to add another div just like it, and another to delete the div itself. I'm trying to create a loop where if there's only 1 of these divs, the "delete" link should hide, and if there are more than 1 of these divs, the "delete" link should show up on all the divs.
So far I came up with this, but no success:
var pCount = $(".phoneNo").length;
$(pCount).each(function(){
if (pCount <= 1) {
$("a.deleteThis").hide();
}
else if (pCount >= 1) {
$("a.deleteThis").show();
}
return true;
});