Home › Forums › JavaScript › Best practice: Remove active state from dropdown menu › Re: Best practice: Remove active state from dropdown menu
July 2, 2012 at 3:36 am
#105199
littleGiant
Member
Hm, maybe I misunderstood what jQuery()
actually does. I thought it searches the DOM using the given selector and returns a set of fitting jQuery objects. If that is true $('.dropdown-button.active').hasClass("active")
will cause a search in the DOM just as $('.dropdown-button.active').removeClass("active")
does. So a DOM search will be performed in both solutions when a click on the document is registered (in your example even twice).
Or am I missing something elemental?