Tip: you can modify some code before running
<html> <head> <title>Event triggered after the value in the text box is changed through js: onpropertychange event</title> </head> <body> <div id="test1"> <b>When the onpropertychange event and onchange event are tested together:</b> <br> <font color="red">Test results: the onpropertychange event is triggered when the value of the text box is changed or the value of the text box is changed using js. The onchange event is triggered only when the value of the text box is changed using the keyboard, trigger after the focus is lost, and use js to change its value does not trigger</font> <br> <input name="haha1" type="text" onpropertychange="alert('触发了onpropertychange事件!')" onchange="alert('触发了onchange事件!')" size="30" > <input name="testbutton1" value="通过js改变文本框中的值" type="button" onclick="document.getelementbyid('haha1').value='js改变文本框后的值'"> <br><br> <br> <div id="test2"> <b>When only onblur and onchange events are tested:</b> <br> <font color="red">Test result: onchange is triggered first, and onblur is then triggered.</font> <br> <input name="haha2" type="text" onblur="alert('触发了onblur事件!')" onchange="alert('触发了onchange事件!')" size="30" > <input name="testbutton2" value="通过js改变文本框中的值" type="button" onclick="document.getelementbyid('haha2').value='js改变文本框后的值'"> <br> <div> <br><br> <br> <div id="test3"> <b>Test when onblur and onpropertychange events are used together:</b> <br> <font color="red">Test result: onblur seems to have a problem. If you enter a value in the text box on the keyboard, it will be triggered. It may be that onpropertychange makes it messy... ^-^</font> <br> <input name="haha3" type="text" onblur="alert('触发了onblur事件!')" onpropertychange="alert('触发了onpropertychange事件!')" size="30" > <input name="testbutton3" value="通过js改变文本框中的值" type="button" onclick="document.getelementbyid('haha3').value='js改变文本框后的值'"> <br> <div> <br><br> <br> <div id="test4"> <b>When onblur, onpropertychange, and onchange events are used in the test:</b> <br> <font color="red">Test results: the onblur and onpropertychange problems still exist.</font> <br> <input name="haha4" type="text" onblur="alert('触发了onblur事件!')" onpropertychange="alert('触发了onpropertychange事件!')" onchange="alert('触发了 onchange事件!')" size="30" > <input name="testbutton4" value="通过js改变文本框中的值" type="button" onclick="document.getelementbyid('haha4').value='js改变文本框后的值'"> <br> <div> </body> </html>
Tip: you can modify some code before running