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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:49:20+00:00 2026-05-26T09:49:20+00:00

(using jQuery 1.4.4 edition) The title of the question might not be that clear,

  • 0

(using jQuery 1.4.4 edition)

The title of the question might not be that clear, that is why I am going into a more detailed description below:

I am trying to trigger some JavaScript code when a selection in one of my select boxes changes. I know that I can do that with the change() as follows:

var my_handler = function(eventObject){
  // ... do something here ...
};
$('#my_select_box').change(my_handler);

The problem is that this is not triggered when user changes selection by keyboard. I searched in Stack Overflow and everybody is suggesting to bind the same handler on keyup event too, as follows:

var my_handler = function(eventObject){
  // ... do something here ...
};
$('#my_select_box').change(my_handler).keyup(my_handler);

Indeed, both when I change the selection by keyboard and when I change the selection by mouse the handler is executed.

The problem is when I change the selection with keyboard and then I move on to the next field (either by mouse or keyboard) in the form. The handler is triggered again (second time)

Can you explain why does this happen and tell me whether there is a way to bypass 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-26T09:49:21+00:00Added an answer on May 26, 2026 at 9:49 am

    The only answer that seems to work is to keep track of the actual change of your value in some way, like a variable outside the event handler. You may not be able to avoid raising the event, but you can choose not to respond to it. The example below illustrates:

    var lastVal = null;
    var my_handler = function(eventObject) {
        if (lastVal == $(this).val()) return;
        console.log("Changed");
        lastVal = $(this).val();
        eventObject.stopPropagation();
    };
    
    $('#my_select_box').change(my_handler).keyup(my_handler);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using jquery's .post i send do my php code an object that with var_dump
Using jQuery, how can I get the input element that has the caret's (cursor's)
Using jQuery 1.6.2 HTML that I'm operating on <select id=langId> <option value=0>Argentina - Spanish</option>
Using jQuery (1.7), and not jQueryUI - (how) would it be possible to accomplish
Using jquery, how can I find the first div that contains an input with
(using jquery) I have the following function $(function() { $('tr.parent') .css(cursor,pointer) .attr(title,Click to expand/collapse)
Using jQuery 1.4.4. When a user mouses over the table element below, I want
Using jQuery, how do you bind a click event to a table cell (below,
Using jQuery Tools from flowplayer.org I'm not understanding how to make my Slides auto
Using jQuery, is there a way to select all tag that reference a specific

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.