looping through new div as they are created
Posted
by eknown
on Stack Overflow
See other posts from Stack Overflow
or by eknown
Published on 2010-03-18T23:04:08Z
Indexed on
2010/03/18
23:11 UTC
Read the original article
Hit count: 197
jQuery
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;
});
© Stack Overflow or respective owner