What other event types does the .on() method take (besides 'click')?

Question

What other event types does the .on() method take (besides 'click')?

Answer

jQuery uses the same event types that JavaScript uses. This includes commonly used keyboard events like keydown and keyup and mouse events like click, mouseenter, mouseleave, and mouseover.

2 Likes

Here’s a useful website for helping you to break the habit of always using jQuery, even for just a few functions: http://youmightnotneedjquery.com/

I think using
$navDropdown.toggle() should be accepted also. It is in my opinion better because the menu dissapears when you click again,

2 Likes