This article mainly introduces the onchange and Onpropertychange in JS (onchange Invalid solution), the need for friends can come to the reference, I hope to help you.
I note: Today I use the onchange event without any reaction, and finally look at the data to know onchange limitations and instability. And Onpropertychange is very good, especially its real-time capture performance is very worthwhile to use (thanks to this performance, to make things the boss is satisfied with O (∩_∩) o ... )。 I am also lazy, I do things are lazy to clean up the search to the original information to share with you: IE, when an HTML element of the property changes, can be captured by Onpropertychange. For example, the Value property of a <input name= "Text1" id= "Text1"/> object is modified by the script of the page, onchange cannot be captured. And Onpropertychange can capture it. (is captured in real time) that is to say: Onpropertychange can capture the changes in property values in time, and onchange when the value of the property changes must also cause the current element to lose focus (onblur) to activate the event! such as: Example 1: Please enter picture address: <input type= "text" name= "mytext" size= "" value= "" onpropertychange= "document.im ages[' myimg '].src=this.value "/> <img id=" myimg "src="/img/common/logo.gif "alt=" "/> when the contents of the text box are changed, The picture will be displayed immediately. If you use onchange, change the value of the mouse click white space or other places to make the INPUT element lose focus (onblur) to activate the event, the picture will be changed! Example 2: <input id= "image" style= "width:448px; height:22px " onpropertychange=" Preview.src=image.value "type=" file "size=" "Name=" File1 "runat=" Server > <img id= "Preview" height= "170" alt= "" src= "" Width= "256" > ---------------------------------------------------------------- Onpropertychange event is so cute, I love it at first sight OnChange: event that the current element loses focus and the content of the element changes to trigger events [mouse and keyboard triggers can be] So when the value of the object is changed by the script, it does not trigger the onchange event, because the user does not move the mouse and does not move the keyboard.