littleGiant
-
Best practice: Remove active state from dropdown menu
I tried to apply you solution to my example where more than one button could appear within the DOM. Don't know if it is worth the effort though, it just feels cumbersome. Solution 1: Remembering the previously clicked button http://jsfiddle.ne…
-
Best practice: Remove active state from dropdown menu
Maybe not a bad idea to cache all .dropdown-buttons first and to use these as context for new .active queries within $(document).click(). http://jsfiddle.net/mGAs4/3/ Currently I do not see a better/easier solution. Thank you for your thoughts!
-
Best practice: Remove active state from dropdown menu
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…
-
Best practice: Remove active state from dropdown menu
That is indeed a better solution than remembering the last element clicked. Thank you kgscott. I adapted your solution so a click on the document removes the "active" class on the button. You have to keep event bubbeling in mind though. …