I have an OL that contains LIs with small inset buttons:
<li id="123">
<button class="action1">Do 1</button>
<button class="action2">Do 2</button>
</li>
And my jquery which has set up the functions on document load:
$('.action1').on('click', function() {
// do stuff
});
Only, when I'm appending to the list:
li = '<li...' //defines li item here
$('#myol').append(li);
The buttons don't do anything. I guess this is because the listeners were attached before the listitem was created, but what is the correct way to attach the listeners to the newly created items (or even better, set them up in such a way that newly created items are accounted for?