SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2006
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reset Toggle when another button is clicked?

    Hi all,

    I have two buttons, both of which are targeting the same ID.
    The problem I have is that if ".close" is clicked, then ".calendar" must be toggled back to the original position before opening #navigation again. I'd rather not have to click it twice.

    Is there a way I can reset .calendar's toggle when .close is clicked? Or can I easily combine the two function to avoid this problem?

    Code:
             $(".calendar").toggle(function () {  
    			$("#navigation").animate({"left": "165px", "opacity": 1}, 500);  },
    			function () {  
    			$("#navigation").animate({"left": "0px", "opacity": 1}, 500);
    	 });  
    	 $(".close").click(function () {  
    			$("#navigation").animate({"left": "0px", "opacity": 1}, 500);  
    	 });

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,075
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Aaron Castillo
    Hello, jcalabro

    You can try this:

    Code:
    $(".calendar").toggle(function () {  
    			$("#navigation").animate({"left": "165px", "opacity": 1}, 500);  },
    			function () {  
    			$("#navigation").animate({"left": "0px", "opacity": 1}, 500);
    	 });  
    	 $(".close").click(function () {  
    			$(".calendar").click();  
    	 });
    --quoted from someone who reported his answer rather than post it
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •