Friday, 15 January 2010

javascript - Add/remove class on click - how do I remove the class on a second click area? -


I have a menu with a dropdown, where element on LI gets an active class on click I have the conflict After a lot of things have succeeded in setting up a script, which sets an active class in a division that is hidden to me, which shows on the click of the site's overlay (under the dropdown). Everything works, like I click outside the dropdown to close it instead of clicking on the menu button. This does not change the class of my overlay div - how do I change my script to work on clicks outside the dropdown, and what should I target here?

Hidden Div:

  & lt; Div id = "site overlay" & gt; & Lt; / Div & gt;  

script:

  $ NoConflict (); ('' '' '' Li ''). ("Click", function () {if (jQuery (this) .hasClass ('active')) {jQuery ("# ​​site overlay") .addClass ("active");} and {jQuery ("# Site Overlay "). RemoveClass (" Active ");}})});  

This will work:

  $ NoConflict (); ('' '' '' Li ''). ("Click", function () {if (jQuery (this) .hasClass ('active')) {jQuery ("# ​​site overlay" "(" active "); addClass (" active ");} Other {JQuery ("# ​​Site Overlay"). RemoveClass ("Active");}}); jQuery ("# ​​Site-Overlay"). Click (function () {JQuery (this) .removeClass (" Active ");});});  

Notice the new event handler.


No comments:

Post a Comment