Prevent onblur code to execute if clicked on submit button

前端 未结 3 1512
长情又很酷
长情又很酷 2021-02-04 12:15

By the following code I wish to \"DO SOMETHING\" on \"ONBLUR\" of element id=\"eg1\" only if the onblur event was not caused due to \"ONCLICK\" on the submit button.

<         


        
3条回答
  •  心在旅途
    2021-02-04 12:44

    A trick -
    
     $(document).ready(function() {  
    var flag = false;
         $('#eg1').blur(function() {
    flag = true;
          if(!($("#SubmitBut").click())) {
    if(flag) 
       return false;            
     //do something
          }
         });
        });
    

提交回复
热议问题