I have a link (avatar)#qam-account-toggle
and div.qam-account-items
, the div containing user account links. I am toggling div on avatar click as well as click anywhere but div.qam-account-items
Here is my code. How can I optimize this better?
$('#qam-account-toggle').click(function(e){
e.stopPropagation();
$(this).toggleClass('account-active');
$('.qam-account-items').fadeToggle('fast');
});
$(document).click(function(){
$('#qam-account-toggle.account-active').removeClass('account-active');
$('.qam-account-items:visible').hide();
});
$('.qam-account-items').click(function(event){
event.stopPropagation();
});