I have a function that appends some HTML to an element. It may get called more than once, so I only want it to append the HTML to elements that haven't already had the HTML added.
Example:
<div class="divToAppendTo"></div>
<div class="divToAppendTo"><span class="myAppendedMarkup"></span></div>
As such, I'd like to select all .divToAppendTo that don't have an immediate child of .myAppendedMarkup
My stab at it doesn't seem to work:
$(".divToAppendTo:not(>span.myAppendedMarkup)")
It always appends when I call it (thereby duplicating the content).