opportunityr opportunityr - 11 months ago 42
CSS Question

Function that detects click outside of element runs when click is inside of element

I'm trying to close an element when I detect a click outside of the element itself, but it seems to be closing the element anyway whenever I click on it.

EDIT: Figured it out.

Answer Source

You have an error in your code, var container = $(".nav-container"); should be var container = $("#nav-container"); you are searching for nav-container as a class rather than an id, # = id, . = class

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download