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.
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