jQuery change event on <select> not firing in IE

前端 未结 10 1884
甜味超标
甜味超标 2020-11-27 05:22

I\'ve got a page with a variable number of

提交评论

  • 2020-11-27 05:34

    If I recall correctly you will need to call blur() to have jQuery invoke change() on IE machines. Try something like:

    $("select[name=mySelectName]").click(function() {
        $(this).blur();
    });
    
    0 讨论(0)
  • 2020-11-27 05:37

    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.

    0 讨论(0)
  • 2020-11-27 05:38

    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.

    0 讨论(0)
  • 2020-11-27 05:40

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

    0 讨论(0)
  • 2020-11-27 05:47

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

    $(document).ready(function(){$('select').bind('onChange',function(){$(this).blur()});});
    
    0 讨论(0)
  • 提交回复
    热议问题