I can't make my button respond to clicks. I generated this button using html() method:
var button1 = '<button class="btn btn-default" id="button1">Back</button>';
$(".component").html(button1);
This button renders on the screen, but doesn't work, nothing happens when I click.
$("#button1 ").on('click',function(e){
console.log("clicked");
});
The same html code inserted by hand (hardcoded) works fine.