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

  • Home
  • SEARCH
  • 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 3224878
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:16:28+00:00 2026-05-17T16:16:28+00:00

I have a href element and that has onclick event on it. I want

  • 0

I have a href element and that has onclick event on it. I want to change the function after some event. I tried using jquery but the old one and new function both are fired. I want only the new one t be fired.

My Code is as:

<a href='#' id='cvtest' onclick='testMe("One")' >TEST</a>
 after some event i am adding following code:
$("#cvtest").click(function(){ testMe("Two"); });  

When i click “Test” link i get 2 alerts “One” and “Two”.

How to stop the first event getting fired or is there any other solution to this problem?

  • 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-05-17T16:16:29+00:00Added an answer on May 17, 2026 at 4:16 pm

    Don’t use the deprecated onclick property. Assign both event handlers using jQuery. Then it’s easy to remove the one you no longer want.

    // Add the original event handler:
    var originalEventHandler = function() { 
        testMe('One');
    };
    $("#cvtest").click(originalEventHandler);
    
    // Then later remove it and add a new one:
    var newEventHandler = function() { 
        testMe('Two');
    };
    $("#cvtest").unbind('click', originalEventHandler).click(newEventHandler);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a -link element that has href link to page, but I have
I have an element like so: <a class='link' href='/page1'>Page 1</a> It has a click
I have two types of links that are event-bound. If the clicked-on link has
I am successfully loading content through the use of jQuery(.menu li a).click( function(event){ jQuery(#loadingArea).load(this.href)
I have an internal website that has a link with NO onClick attribute present.
i have some div element that scrolls to another position, when you click on
I have an href in HTML that I dynamically produce from a server. I
i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
I have a WebBrowser control and try to set onclick and href attributes on
I have a Ajax request that fires on clicking a href that is part

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.