Tuesday, 13 December 2016

html - jQuery click function doesn't work after ajax call?

Since the class is added dynamically, you need to use event delegation to register the event handler like:


$('#LangTable').on('click', '.deletelanguage', function(event) {
event.preventDefault();
alert("success");
});

This will attach your event to any anchors within the #LangTable element,
reducing the scope of having to check the whole document element tree and increasing efficiency.


FIDDLE DEMO

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...