In my project I am appending several buttons to a div:
$(".tab-content").append("<div class='landing_content'><button class='off-screen-nav-button btn btn-info btn_edit' data-effeckt='effeckt-off-screen-nav-right-overlay'>Edit</button></div>");
and then listen for a click with the following code:
$(".tab-content").on("click",".btn-edit",function(){
console.log('edit');
});
Why is this not working? I am used to use .live() but it has been deprecated.
Thanks.
In your markup you have btn_edit
and in your jQuery you have btn-edit
.
Change your markup class
to match the jQuery selector, like this:
$(".tab-content").append("<div class='landing_content'><button class='off-screen-nav-button btn btn-info btn-edit' data-effeckt='effeckt-off-screen-nav-right-overlay'>Edit</button></div>");