jquery click event not fired on internet explorer

后端 未结 3 1456
无人共我
无人共我 2020-12-21 08:30

I am trying to do something when user clicks on label.

I am trying to get the click event fired It is

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 08:50

    this is what i had to do to get things working properly. best i can guess, the call to focus() also causes it to lose focus which is what fires the change event for IE.

    also, a note on the suggested .click() method... while this will allow an event to fire, so that code can be ran, it does not cause the to lose focus, so the selected index & value are never changed (at least in my case). i event went so far as to call .trigger('change') from the click event in an attempt to force the change, and while the event would fire, the selected option never changed.

    i know it is a hack, but it works pretty damn well IMO

    // IE hack to get change event to fire properly
    if ($.browser.msie) {
        $('select').on('mouseover', function (e) {
            $(e.target).focus();
        });
    }
    

提交回复
热议问题