Event Handlers

Hi, so i finished the event handlers lesson on jQuery where we use the .on() method to create an event handler object. at the end of the lesson the task is to create a command for an onclick event to show an element on the HTML page. i was trying to come up with a simple way of reversing this method and came up with:

if ($navDropdown.show() = true;) {
$menuButton.on(‘click’, () => {
does this not work because .show() does not evaluate to true or false? How would one make a simple command for resetting the element to being hidden, thanks for all help given


The code you’re looking for hasn’t been covered in the course at this point. This would work:

if ($navDropdown.is(":visible")) {
} else {

The above code is similar to what you were trying to do, but soon you will come across the toggle() method which makes this much simpler. Happy coding!