I'm trying to select a button that is made using a jQuery statement. This is the button:
$('#mainTable').append('<tr><td>' +
elem.date + '</td><td><button class="dButton">Click here</button></td></tr>')
Then here's the selector for the button:
$(".dButton").click(function () {
alert("alert");
})
I've checked that the top bit of code is called first so the button is created first, and then the second bit, but whenever I click the button it just won't run the second bit of code.