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 8712241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:04:12+00:00 2026-06-13T05:04:12+00:00

I have multiple clicks, that I have to unbind once clicked on, but I

  • 0

I have multiple clicks, that I have to unbind once clicked on, but I need to rebind the button for the links.

Here is an example :

$('.001').click(function(){
      jQuery(this).unbind('click');
      jQuery('.hide').hide();
      jQuery('.show').show();
      jQuery(this).find('.show').hide();
      jQuery(this).find('.hide').load('pages/001.html');
      jQuery(this).find('.hide').show();

    }); 

    $('.002').click(function(){
      jQuery(this).unbind('click');
      jQuery('.hide').hide();
      jQuery('.show').show();
      jQuery(this).find('.show').hide();
      jQuery(this).find('.hide').load('pages/002.html');
      jQuery(this).find('.hide').show();
    });

So when I click on .001 it loads a page with a different jQuery action in it (a slider), so I must unbind the click on .001 (hence the jQuery(this).unbind(‘click’);), BUT when I click on .002 I must rebind the .click on .001. This must be done with vars because this can go from 001 to 999.

Any tips ?

  • 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-13T05:04:13+00:00Added an answer on June 13, 2026 at 5:04 am

    You don’t need to bind and rebind handlers again and again. Just store the identifier of the activated item somewhere, then check for it in each click handler. Like this:

    var active;
    $('.some_class').click(function() {
      if (this.className === active) {
        return false;
      }
      active = this.className;
      ...
    });
    

    Also, I’d highly recommend assigning one and only one function as event handler for all the items in question, forking its actions based on external attribute. Like this:

    <a class="first" data-url-to-go="/first.html">Some Link</a>
    <a class="second" data-url-to-go="/second.html">Some Other Link</a>
    ...
    var active;
    $('.first, .second').click(function() {
      if (this.className === active) {
        return false; 
      }
      active = this.className;
      var $this = $(this), 
          url = $this.data('urlToGo');
      ...
    });
    

    Here’s a JS Fiddle that illustrates this concept.

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

Sidebar

Related Questions

I have multiple forms that popup during an intensive operation. For example, when a
I understand that if I have multiple markers on a map, and I need
I think I have a problem with multiple clicks on the same button. I
I have a button/link. I want to open multiple divs on multiple clicks on
I have a submit button and the following code that does something once its
I have multiple ajax requests with javascript code as response, and I need to
I have multiple image galleries that use the following code (simply view the demo
I have some code that when a user clicks on a link Add Comment,
I have multiple pieCharts in my flex app and when the user clicks a
So I have multiple textareas on my page that are editable depending on a

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.