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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37acc-2c0bf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37acc-2c0bf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?