Skip to main content

How do you handle events in jQuery?

Entry JQuery
Quick Answer jQuery event handling: $(".btn").on("click", handler) - attaches a handler for the click event. .on() replaces the old .bind(), .live(), .delegate(). .off() removes handlers. .trigger("click") programmatically fires an event. .one() attaches a handler that fires exactly once. For delegated events: $("ul").on("click", "li", handler) - handles clicks on dynamically added li elements.

Answer

Use .on() to bind events: click, keyup, hover.
.off() removes handlers.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice