Can i prevent blur event from happening?

后端 未结 4 1403
我在风中等你
我在风中等你 2021-01-08 01:25

I have a simple example where i have an input field and i put a blur and change event on it:

HTML

<         


        
相关标签:
4条回答
  • 2021-01-08 01:51

    Solved issue by this..

     $('input').change(function(e){
      alert('change'); 
       e.stopImmediatePropagation();
       $(this).off("blur");
     });
    
    $('input').focus(function(e){
       $(this).on("blur", function(e){
       e.stopImmediatePropagation();
       e.preventDefault();
      alert('blur'); });
    });
    
    0 讨论(0)
  • 2021-01-08 01:56

    you can use

    this.unbind('blur'); on the onchange call

    0 讨论(0)
  • 2021-01-08 02:03

    use .off

    DEMO

    $('input').change(function(e){
      alert('change'); 
      e.stopImmediatePropagation();
      $(this).off("blur"); //$("input[name='test']").off("blur");
    });
    
    $('input').blur(function(e){  
      e.preventDefault();
     alert('blur'); 
    });​
    
    0 讨论(0)
  • 2021-01-08 02:06

    If I understand you correctly the answer is to use event.preventDefault(); See http://jsbin.com/welcome/52201/edit for a demo.

    0 讨论(0)
提交回复
热议问题