I have buttons that was created dynamically. How to add a jquery onclick on this button? I am still new to jQuery.
This is how I created my buttons in jQuery:
var language_add_button = document.createElement("button");
language_add_button.setAttribute("id", "btnRemoveLanguage_" + ctr);
language_add_button.setAttribute("class", "btn btn-padding");
language_add_button.setAttribute("type", "button");
This function creates buttons with id + ctr making them unique.
I know about
$("#btnRemoveLanguage_").click(function (e) {
RemoveLanguage(true);
e.preventDefault();
});
But since there is a counter when created, the buttons becomes btnRemoveLanguage_1, btnRemoveLanguage_2, etc.
How do I make sure that it is clicking the right button?