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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:44:27+00:00 2026-06-12T23:44:27+00:00

I have found that the following behavior in Chrome, not in Firefox. I have

  • 0

I have found that the following behavior in Chrome, not in Firefox.

I have an input element, which

  • has "change" event handler
  • has "keydown" event handler, in which when user types backspace and the element content is none, then that element is removed.
  • and those two handlers are bound to some wrapper element, and the event handlers are attached using jQuery.on function, as a delegated handlers.

In Chrome, If I

  1. click input box, type some text in input box, and focus out.
  • change event handler is called.
  1. click input box, type backspace(s) to remove all the contents, and type once more to remove that input box.
  • then, change event handler is still called though the target input DOM is removed!

In Firefox, when the box is removed due to backspace keydown, the change event handler is not called..

Is is only in my browsers? or jQuery bug? or browser implementation bugs?

I wrote the simplified code in jsfiddle..
http://jsfiddle.net/RbAua/6/

  • 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-12T23:44:28+00:00Added an answer on June 12, 2026 at 11:44 pm

    If you use bind() on change event it works as expected,

    seems bug related to on() method, that why i not understand why last time all use .on() even for single element!

        http://jsfiddle.net/RbAua/9/

    $('#wrap').on('keydown','#input',function(event){
        if(event.keyCode == 8){ // backspace
            if($(this).val().length == 0){
                $(this).remove();
                $('#txt').append('<div> removed! </div>');
                event.preventDefault();
            }
        }
    });
    
    
    $('#wrap #input').bind('change', function(){
        $('#txt').append('<div> changed! to [' + $(this).val() + '] </div>');
    });
    

    debugging jquery, i have found that if event has been applied with on() or live(), then element not have a cached event data, so CleanData() not works as expected, in this case more strange that FF works as expected out of the box.

    i found workaround for this, idea is to bind only to visible elements, so making
    hide() before remove will prevent change fire.

    var onchange = function(e) {
        $('#txt').append('<div> changed! to [' + $(this).val() + '] </div>');
    };
    
    $('#wrap').on('keydown', '#input', function(event) {
        if (event.keyCode == 8) { // backspace
            if ($(this).val().length === 0) {
                var that = $(this);
    
                var onchange1 = onchange;
                that.hide();
                that.remove();
                $('#txt').append('<div> removed! </div>');
                event.preventDefault();
            }
        }
    });
    
    
    
    $('#wrap').on('change', '#input:visible', onchange);​
    

    http://jsfiddle.net/RbAua/12/

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

Sidebar

Related Questions

FINAL EDIT: After following the answer from Darin Dimitrov, I have found that the
I have some questions regarding the following css that I found: html, body {
I have found that dragend event in Google Map also trigger the click event
I have found that I have no problem using require to load something like
I have found that call stack helps in finding the line number of a
I have found that it is impossible to write ( file_put_contents or simple fwrite
I have found that how to determine what columns are primary key column of
I have found that I often have to implement some sort of a scheduler
I have found that creating a zip file using the Zip task provided by
We have found that with our memcache some keys tend to be lost. To

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.