Reputation: 23
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
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
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