How can you attach an event handler to an element in jQuery?
Instruction: Describe the process of attaching click and hover event handlers to a button using jQuery.
Context: This question tests the candidate's knowledge of event handling in jQuery and their ability to apply it to user interactions.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Use .on to bind events. For hover entry and exit, bind mouseenter and mouseleave explicitly. Use a real button so its click action also supports keyboard activation; essential behavior must not depend on hover.
Load jQuery before this complete example:...