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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:05:59+00:00 2026-05-19T09:05:59+00:00

I am attempting to handle multiple concurrent events using jQuery but I am having

  • 0

I am attempting to handle multiple concurrent events using jQuery but I am having problems finely managing when the events are fired.

<html>
  <head>
  <title></title>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  </head>
  <body>

    <div id="edit" contenteditable="true">Edit some content</div>
    <button id="button" type="button">Click the button</button>

    <script type="text/javascript">
      $(document).ready(function () {
        $('#button').click(function (e) {
          alert('I have been clicked.');
        });
        $('#edit').blur(function (e) {
          alert('I have been edited.')
        });
      });
    </script>

  </body>
</html>

What I wish to achieve is for the content of the DIV to be edited by a user and when the button is clicked, for that event to be raised before the blur event on the DIV. It may be the case that the button is never clicked in which case the blur event may fire on its own. As you can see using the code above, once you edit the content and click the button only the blur event is fired.

Please can someone advise how I may achieve the desired functionality?

  • 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-19T09:06:00+00:00Added an answer on May 19, 2026 at 9:06 am

    One — admittingly very hacky — way would look like this:

    $(document).ready(function() {
        var buttonClicked = false;
        $('#button').bind('click', function(e) {
            buttonClicked = true;
            alert('I have been clicked.');
        });
        $('#edit').bind('blur', function(e) {
            setTimeout(function() {
                if (!buttonClicked) alert('I have been edited.');
                buttonClicked = false;
            }, 100);
    
        });
    });
    

    This example doesn’t prevent the firing of the event, though. It only handles the callback.

    Here it is working: http://jsfiddle.net/Dp6b5/1/
    You can adjust the timeout delay and don’t necessarily have to use bind in this case either.

    It’s an interesting question, but I don’t see any “proper” way to handle this atm., since the blur event is de facto fired before the click. Maybe someone else has a better idea I can’t see atm..

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

Sidebar

Related Questions

I am attempting to have a ReportHandler service to handle report creation. Reports can
I am attempting to load multiple images in AS3 and I'm exploring different options
I'm attempting to string match 5-digit coupon codes spread throughout a HTML web page.
I'm attempting to re-organize my application's namespace hierarchy, so I'm using a System.Runtime.Serialization.SerializationBinder sub-class
I'm attempting to download a zip file using this code: o = urllib2.build_opener( urllib2.HTTPCookieProcessor()
I am attempting to pull some information from my tnsnames file using regex. I
I'm attempting to design a system that will allow the processing of multiple types
I attempting to handle the insert of a new master record and associated child
I'm attempting to use ImageMagick along w/ Paperclip to handle the images on my
Attempting to insert an escape character into a table results in a warning. For

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.