jQuery change event on is blurred. – Justin Stayton Oct 28 '09 at 14:27

  • 1
    I don't think blur automatically fires change. however, blur is propagated properly, so a solution might be a delegated blur event which fires the change event (you could even save the old value as data if you want to check if it's changed). This is a hack. Unfortunately the proper solution requires MS to fix old IE versions – Adam Dec 20 '11 at 09:24
  • 3

    using jquery 1.4.4 (and i think 1.4.3) seems to be all good now.... the change event works consistently in my limited testing.

    user406905
    • 1,418
    • 15
    • 16
    • I'm using jQuery 1.7. It works for selects which are on the page when it loads, but not for those dynamically added afterwards (I add a new row when you fill in the last existing row). The problem appears to be limited to IE 8 and below. – Adam Dec 20 '11 at 09:22
    1

    onchange=doAction will work in IE and Firefox, but its not supported in Chrome.

    You need to use jQuery's .change event to handle this.

    Littm
    • 4,923
    • 4
    • 30
    • 38
    Madhura
    • 21
    • 1
    • 4
    1

    Add this lines to your page head, Sit back and relax! :)

    $(document).ready(function(){$('select').bind('onChange',function(){$(this).blur()});});
    
    Soheil
    • 11
    • 1
    0

    IE requires change event to be placed inside document ready. This seems to bind the change event to the associated element. Hope it helps.

    0

    I'm trying to understand why you need to double check the name of the select after receiving an event to it.

    Do you by any chance have multiple elements with the same id ?

    Did you actually mean to say "#container select" instead of "#container" ?

    Maciek
    • 3,322
    • 6
    • 28
    • 35
    • 1
      No. I'm using event delegation because I don't want to attach the event to every single – Justin Stayton Oct 28 '09 at 14:22
    • And there are other – Justin Stayton Oct 28 '09 at 14:23
    • You can add an ID to the select element itself – Mottie Oct 28 '09 at 14:44
    0

    I'm simply building upon the example set by "Crescent Flesh" for a cross-platform solution that will survive even if loading this SELECT inside #container via an AJAX call.

    $('#container').bind($.browser.msie ? 'click' : 'change', function(event) {
      if ((event.type == 'click') || (event.type == 'change')) {
        if (event.target.toString().indexOf('Select') != -1) {
          var sWhich = $('#container SELECT').val();
          handleSelectionChange(sWhich);
        }
      }
    });
    

    Now you simply build the handleSelectionChange() function, renaming it whatever you want.

    Volomike
    • 23,743
    • 21
    • 113
    • 209
    -2

    :D:D Wow, I was finding solution... Why think so complicated? Simply:
    <select onchange="doAction">

    Jaroslav Štreit
    • 415
    • 1
    • 5
    • 16