Having trouble where my ‘p’ element value is being appended to both ‘review-comment-wrap’ blocks. I think the issue may be that in my append function the 'p' element is being appended to all the review-comment-wrap elements. How do I append only to the 'review-comment-wrap' block where the element with the value B was removed?
<div class="reviewer-meta">
<div class="author-attribute">Value A</div>
<div class="author-attribute">Value B</div>
</div>
<div class="review-comment-wrap">some value</div>
/** add appended value here only **/
<div class="reviewer-meta">
<div class="author-attribute">Value A</div>
</div>
<div class="review-comment-wrap">some value</div>
function runProgram(){
var theElements = $('.reviewer-meta').find('.author-attribute');
$(theElements).each(function(){
if(this.innerHTML == "Value B"){
$(this).remove();
}
});
$('.review-comment-wrap').append('<p>New value</p>');
}
runProgram();