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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:08:23+00:00 2026-06-08T10:08:23+00:00

I have a question about event click and order of execution. I make a

  • 0

I have a question about “event click” and “order of execution”.

I make a example here ( The HTML is generated by a external javascript ) :

HTML:

<a href="#" id="comments-replybutton" onclick="alert('Action');return false;">Comment</a>​

JavaScript:

$(document).ready(function(){
    $('#comments-replybutton').click(function(){
        alert('2 attach event');
    });
});​

I want that when do click in “Comment” first execute the action of jquery (bind event).

Is this possible?

  • 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-08T10:08:24+00:00Added an answer on June 8, 2026 at 10:08 am
    $(document).ready(function(ev){
        $('#comments-replybutton').click(function(ev){
            alert('2 attach event');
            ev.stopPropagation();
        });
    });​
    

    You mean, like this?

    Edit after comment

    You can also name your function to unbind:

    var myEventHandler = function myFunction(ev){
        $(this).unbind(myFunction);
        alert('attach event 2');
        ev.stopPropagation();
    }
    $('#comments-replybutton').bind('click', myEventHandler); 
    // $(something).click(fn) is just a shorthand to $(something).bind('click', fn);
    

    Edit 2

    I guess you can kill off the original event easily, just by saying document.getElementById(‘comments-replybutton’).onclick = “” or something similar. You can re-attach it by copying before:

    var original_event_handler = $('#comments-replybutton')[0].onclick;
    $('#comments-replybutton')[0].onclick = "";
    $('#comments-replybutton').click(original_event_handler);
    

    A bit dirty, but I’m too lazy to look it up :S preventDefault won’t help you here, though.

    http://jsfiddle.net/C37ka/

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

Sidebar

Related Questions

I have a little question about the click event and qtip2. After the first
I want to ask a question about the JavaScript event. I have an <input
I have a question about the 'Event Dispatch Thread'. I have a Main class
I have question about parsing in Html helper : I have sth like: @foreach
I have question about XSLT1.0. The task is to write out in HTML all
I have a question about C# Event naming conventions: private void button21_Click(object sender, EventArgs
I have got a question about event and bound command. What happens if I
My question is about handling Enter key press.I have one page called order.aspx which
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about normalization. Suppose I have an applications dealing with songs. First

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.