Learn JQuery - Learn JQuery - Event Handlers Cheatsheet - Codecademy
Learn JQuery - Learn JQuery - Event Handlers Cheatsheet - Codecademy
$('#menu').show();
});
$('#textbox').on('keyup', () => {
$('#menu').show();
});
$('#menu-button').on('scroll', () => {
$('#menu').show();
});
type (the event type) and currentTarget (the individual $('#menu').on('click', event => {
DOM element upon which the event occurred). // $(event.currentTarget) refers to the
'#menu' element that was clicked.
$(event.currentTarget).hide();
});
$(event.currentTarget).hide();
});
jquery on method chaining
jQuery .on() event listener methods can be chained
together to add multiple events to the same element. // Two .on() methods for 'mouseenter' and
// '#menu-button' element.
$('#menu-button').on('mouseenter', () => {
$('#menu').show();
}).on('mouseleave', () => {
$('#menu').hide();
});
jquery on method
The jQuery .on() method adds event listeners to jQuery
objects and takes two arguments: a string declaring the //The .on() method adds a 'click' event to
event to listen for (such as ‘click’), and the event handler the '#login' element. When the '#login'
callback function. The .on() method creates an event element is clicked, the callback function
listener that detects when an event happens (for example:
will be executed, which reveals the
when a user clicks a button), and then calls the event
'#login-form' to the user.
$('#login-form').show();
});