The blur event cannot occur

    <table>
          <tr>
              <td></td>
             <td><input type="text" class="data"></td>
          </tr>
          <tr>
              <td></td>
              <td><input type="text" class="data"></td>
          </tr>
      </table>

bound functions

    function  fix(event){
        console.log("haha");        
    }
    document.addEventListener("blur",fix,true);

Why is the blur event not triggered, console.log (""); not executed when the focus is moved away from an input?

Aug.05,2021

nothing wrong. I don't know what your problem is.


Brother, you have to add the event to the input element. You can't add it to document. It's not like document loses focus


.

you can also trigger the blur event without specifying a specific element.
I can trigger it here. No problem. Here are the examples of codepen , which can be viewed on the F12 console:
blur test

.

result:


addEventListener? is not supported in the lower version of ie

Menu