I have an empty div <div id="content"></div> to which I add content via jquery append.
$('#content').append('<div class="sub">sub1</div>');
$('#content').append('<div class="sub">sub2</div>');
$('#content').append('<div class="sub">sub3</div>');
When I click a button I want to run a jquery that reads the content of each sub, but I get nothing, I think because the div elements were added via javascript, so they’re not really on the page.
$('.sub').each(function(){
alert($(this).text());
}
How can I still operate on html added via javascript?
It’s
$('.sub')not$('sub')for classes.