Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
jQuery Core & DOM Manipulation 14 mins read Free Lesson

jQuery Event Handling & Event Delegation

Handle user clicks, keyup, submit, hover, and attach delegated listeners with .on().

Modern Event Delegation with .on()

// Event delegation works for elements dynamically added later!
$("#todo-list").on("click", ".delete-btn", function() {
    $(this).closest("li").fadeOut(300, function() {
        $(this).remove();
    });
});