Why Internet Explorer checkbox accepts double click but changing state only once?

前端 未结 4 1958
谎友^
谎友^ 2021-02-12 12:35

In Internet Explorer (any version) if you click twice fast a checkbox it changes only once. Another browsers don\'t do this.

This is \"by design\" or a very strange beha

4条回答
  •  爱一瞬间的悲伤
    2021-02-12 13:15

    The below code works for me:

    
    
    var temp;
    function toggleGetSelected(e){
            if(e){
    
                // Below is the if condition which handles the double click
                if(e.checked==true && temp==e.value ){
                      e.checked=false;
                }
                // ends double click handle
    
    
                if(e.checked==true){
                    temp=e.value;
                    // your code here                       
                }
                else{
                    temp=null;
                    // your code here           
                }
    
          }
    }
    

提交回复
热议问题