Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:53:29+00:00 2026-06-14T19:53:29+00:00

By pressing the first button, you will animate the margin-left of the second one,

  • 0

By pressing the first button, you will animate the margin-left of the second one, by pressing the second one, you unbind the click event from the first one, but I want lets say a third button to bind the click event back to the first one.

Looking for a simple solution of course!

This is what the code looks like:

<div class="button"><a href="http://www.google.com">something</a></div>
<div class="button2"><a href="http://www.google.com">something2</a></div>
<div class="button3"><a href="http://www.google.com">something3</a></div>

​(function(){
    $('.button a').on('click', function(e){
         e.preventDefault();
        $('.button2').animate({'margin-left': '+=2'}, 100);       
    })

    $('.button2').on('click', function(e){
         e.preventDefault();
         $('.button a').unbind('click');       
    })

    $('.button3').on('click', function(e){
         e.preventDefault();
         $('.button a').bind('click');       
    })

})();​

and you can mess around with it here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:53:31+00:00Added an answer on June 14, 2026 at 7:53 pm

    You can actually use named functions in .on(). What this means is that you can define a function marginFunc(), and then bind it to the click using

    function marginFunc() {
     ...
    }
    
    $(someElement).on('click', marginFunc);
    

    Then once you are done, you can unbind it using either .unbind('click', marginFunc) or .off('click', marginFunc).
    Afterwards, you can rebind in the same fashion as you did at the beginning.

    Working jsfiddle here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pressing the button the first time stops Sound. But pressing it after that does
I've made a fiddle from my problem http://jsfiddle.net/bYMGZ/7/ The first popup displays from pressing
I've heard that pressing the back button will essentially cause the current Activity to
I am using onKeyDown for handling the back button but on pressing the back
How can you open windows program by pressing a button on web page I
when we press a key and keep pressing it the keypress and keydown event
I am trying to create a floating Context Menu when long pressing a button.
For example, In an ActivityA there's a button to create an Intent that will
I created a simple window with two buttons, the first one calls a function
im newbie developer and creating my first iphone app... and i have one little

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.