stoppropagation - Function triggered when click outside an element in jQuery -
i want show different elements in loop when click on body, except element #search-container form
. works, if first click on element #search-container form
, , works once.
$('html').click(function(event) { $('#search-container form').click(function(event){ event.stoppropagation(); }); $('html').on('click',function() { $('#small-search a').toggleclass('notvisible'); $('#session').toggleclass('notvisible'); $('#search-container').css('position','absolute'); $('#search-container form').toggleclass('visible'); }); });
$('html').not("#search-container form").on('click',function(){ $('#small-search a').toggleclass('notvisible'); $('#session').toggleclass('notvisible'); $('#search-container').css('position','absolute'); $('#search-container form').toggleclass('visible'); });
Comments
Post a Comment