JQUERY: Close a div if user clicks outside of it -
i have hidden div opens user clicks on the title (notifications). "subpanel" div hidden default, using jquery toggle open/close when user clicks on word notifications.
how can modify jquery if user clicks outside of div toggled open (subpanel), trigger subpanel close/hide ?
<div class="notiftitle" id="notiftitle"> <a href="#" class="alerts">notifications</a> <div class="subpanel"> <div id="title">new notifications</div> <ul> <li>data</li> </ul> </div> </div> $(document).ready(function(){ //switch "open" , "close" state per click slide up/down (depending on open/close state) $(".alerts").click(function(){ $(this).toggleclass("notiftitleactive"); $(this).toggleclass("active").next().slidetoggle(50); return false; //prevent browser jump link anchor }); });
it sounds need "outerclick"-event. ouerclick jquery plugin jon kassen.
Comments
Post a Comment