JQuery: on method (Team Treehouse Notes)
Instead of having 2 separate event listeners for click and keypress, use the on method to combine the two:
$('#element').on('click keypress', function() {
//do stuff when element is clicked OR when a key is pressed
});
$('#element').on('click keypress', function() {
//do stuff when element is clicked OR when a key is pressed
});
Comments
Post a Comment