Home › Forums › JavaScript › jquery script strange issue › Re: jquery script strange issue
June 27, 2012 at 1:44 am
#104915
Member
First off, don’t bind a click function inside of another click function. It just keeps adding more and more events the more you click on it.
I think the easiest solution would be to bind to all of the links inside the header and close (fadeOut) the header after the click. In this example, only the link with the class close would get a return false, preventing a window location change. All other links would execute. Here is an updated demo, and the code:
$("#header").hide();
$("#header").find("a").on("click", function() {
$(this).parents("#header").fadeOut("slow");
return $(this).hasClass('close') ? false : true;
});
$("a#toggle").click(function() {
$("#header").fadeToggle("slow", "linear");
});