RE7A
RE7A

Reputation: 23

Slide menu reomove when I clicking window

The following code works true but. How do I remove her action when clicking window or document?

$(document).ready(function(){
 $("#icon").click(function(){
     if(! $("#icon").hasClass('active')){
    $("#icon").toggleClass('active');
     $("body").animate({ margin: "0 0 0 350px" }, 400 );
        $('body').css({
          'overflow': 'hidden',
          'height': '100%'
          });
     }else{
        $("#icon").removeClass('active');
         $("body").animate({ margin: "0 0 0 0" }, 400 );
         $('body').css({
          'overflow': 'auto',
          'height': 'auto'
          });       
     }


 });
});

Upvotes: 1

Views: 26

Answers (2)

Zakaria Acharki
Zakaria Acharki

Reputation: 67525

You can use window, document selectors and unbind click event using jquery method off() :

$(window ,document).click(function(){
    $("#icon").off('click');
});

Hope this helps.

Upvotes: 2

Ray Lloy
Ray Lloy

Reputation: 171

To remove action you can use two jquery functions to disable events. http://api.jquery.com/off/ and http://api.jquery.com/unbind/.

$(window,document).bind("click",function(){
   $("#icon").unbind("click");
   // or use
   $("#icon").off("click");
});

Upvotes: 1

Related Questions