On click - jQuery event problems -
i'm trying create function, after clicking on button, open search box, , after clicking again on same button close it.
i have build this:
 $("#searchbutton").click(function(){       $("#searchbox").animate({top: '0px'}, 500),          $(this).click(function(){         $("#searchbox").animate({top: '-47px'}, 500)             });         });   it works fine first time after click on it. if i'll click on again re-open without refreshing page button automatically hide.
why happening?
thank in advance
dom
your problem never unbind first click handler.
the best solution use toggle handler, this:
$("#searchbutton").toggle(     function () { $("#searchbox").animate({top: '0px'}, 500); },      function () { $("#searchbox").animate({top: '-47px'}, 500); } );      
Comments
Post a Comment