onchange on radiobutton not working correctly in IE8

后端 未结 3 1294
天命终不由人
天命终不由人 2020-12-14 01:56

I\'m forced to work with IE8 (8.0.7601.17514) and I have this simple page:



        
3条回答
  •  一生所求
    2020-12-14 02:35

    In Internet Explorer (up to at least IE8) clicking a radio button or checkbox to change its value does not actually trigger the onChange event until the the input loses focus.

    Thus you need to somehow trigger the blur event yourself.. one suggestiong would be to have a function: as follows:

    function radioClick()
    {
     this.blur();  
     this.focus();  
    }
    
    
    
    

    Now your onchange event should be triggered but as you can see it is redundant code thus you are better off just using the onclick event handler.

    The better solution is to use a modern javascript library like jquery which handles all these quirks for you..

提交回复
热议问题