How to tell whether input is entering or deleting?

how to tell whether input is being entered or deleted

Jul.17,2022

1, to judge the change, input is an increase in the number of words, deletion is a decrease in the number of words. The bidirectional binding of
2 and defineProperty is actually used to judge the number of words, but this lower version of IE does not support


    .
  1. listens for change events and then determines whether the length of the value increases or decreases.
  2. listens for the keypress event and then determines whether to press the delete key.

<body >
    <input type="text">
    <div></div>
<script>
    let dom = document.getElementsByTagName('input')[0];
    let value = dom.value;
    dom.oninput=()=>{
        let new_value = dom.value;
        if(value.length<new_value.length){
            document.getElementsByTagName('div')[0].innerHTML = "";
        }else{
            document.getElementsByTagName('div')[0].innerHTML = "";
        }
        value = new_value;
    }
</script>
</body>
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-1b2b505-40010.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-1b2b505-40010.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?