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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:46:01+00:00 2026-06-11T18:46:01+00:00

I have an anchor that triggers some events when it is clicked, and adds

  • 0

I have an anchor that triggers some events when it is clicked, and adds a new class and removes the old one, but when I click it again with the new class the original event is triggered again (like if the class was not removed at all). I tried the .live() function but didn’t help (toggleclass() didn’t work either).

Does anyone know what’s going on on this one?

$('.no-cuenta').click(function(e) {
    e.preventDefault();

    $('.login-inputs').hide('drop', 1000, function(){
      $('.register-inputs').show('drop', 1000);
      $('.no-cuenta').empty().text('Ya tienes cuenta? Ingresa').addClass('si-cuenta').removeClass('no-cuenta');
    });
  });

  //Cargar la forma para loggearse
  $('.si-cuenta').live('click',function(d) {
    d.preventDefault();

    $('.register-inputs').hide('drop', 1000, function(){
      $('.login-inputs').show('drop', 1000);
      $('.si-cuenta').empty().text('No tienes cuenta? Registrate').addClass('no-cuenta').removeClass('si-cuenta');
    });
  });
  • 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-11T18:46:02+00:00Added an answer on June 11, 2026 at 6:46 pm

    You should use the .on() method to bind the click event handlers to a delegate. This makes sure the handlers are bound to any elements with the indicated class, even if they are created later on.

    Note that the following code makes the bodyelement your delegate to handle these click events, you should use the closest common parent that makes sense as a ‘manager’ for these elements:

    $("body").on('click', '.no-cuenta', function () {
        e.preventDefault();
    
        $('.login-inputs').hide('drop', 1000, function(){
            $('.register-inputs').show('drop', 1000);
            $('.no-cuenta')
                .empty()
                .text('Ya tienes cuenta? Ingresa')
                .addClass('si-cuenta')
                .removeClass('no-cuenta');
        });
    });
    $("body").on('click', '.si-cuenta', function () {
        d.preventDefault();
    
        $('.register-inputs').hide('drop', 1000, function(){
            $('.login-inputs').show('drop', 1000);
            $('.si-cuenta')
                .empty()
                .text('No tienes cuenta? Registrate')
                .addClass('no-cuenta')
                .removeClass('si-cuenta');
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of anchor tags that I want to select. But if
I have some mark-up like: <th>Header <a class=uiFilter>Filter</a></th> and some code like: $('.uiGridHeader th').click(theadClick);
I have an event that triggers upon a treeview node click, this then creates
I have an anchor that triggers a javascript which uses jquery: <a href=javascript: $('#dash-main').load('billing.php')>text</a>
I have some links that have events bound to them and some links that
I have an anchor that doesn't go anywhere but has an onclick (e.g. <a
I have a anchor tag that when you click on the Up to the
I have two anchor tags that differ only because the second one does not
I have an anchor tag that has a jQuery click event linked to it.
I have a variety of anchor tags and input buttons that trigger a variety

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.