I am creating some buttons in my jQuery mobile website dynamically. I create them like this:
$('#Gallery' + i + ' .gallery').after('<button type="button" class="loadMorePhotos">More Photos...</button>');
Then I create a simple .click
event handler like this :
$(".loadMorePhotos").click(function(){
alert("ok malaka!");
});
I was cautious enough NOT to use the id
attribute to identify the buttons , as I have multiple buttons and that would mess things up. Instead I use the class
attribute that as far as I understand should work.
However the alert is never executed. What could I be doing wrong here?