I'm trying to execute a JQuery function that will unput text in an empty div (if it is empty) for each element under the div id "answerrr" however the script will only search for the first div and add text to that, and it disregards the rest. Perhaps I'm using the .each() function incorrectly?
<b><div id="answerrr"></div></b>
<b><div id="answerrr"><p>Not Empty</p></div></b>
<b><div id="answerrr"></div></b>
<script>
$('#answerrr').each(function() {
if ($('#answerrr').is(":empty")) {
$('<p>Empty!</p>').appendTo($(this));
}
});
</script>
Also, if my page were to load more content through Ajax, how would I go about ensuring that this script is re-executed