Input _ text box enter or lose cursor trigger event

Source: Internet
Author: User

Under IE, when a property of an HTML element changes, it can be captured instantly via Onpropertychange.
OnChange must also cause the current element to lose Focus (onblur) when the property value changes to activate the event.
To understand this, we find that the effect of Onpropertychange is what we want, but unfortunately, it only works under IE. Can we find another time to replace Onpropertychange?
Through the data learned that in other browsers can use the Oninput event to achieve the same effect, it is very good, we just need to distinguish the IE browser can be.

If you are writing the registration time directly in the page, then the following can be implemented:
oninput= "alert (this.value);" onpropertychange= "alert (this.value)"

PropertyName: is used to get which property has been modified.

<input type= "text" value= "xxx" id= "xx" onclick= "this.myprop= ' xx '" >    <script type= "Text/javascript" >         document.getElementById (' xx '). attachevent (' Onpropertychange ', function (o) {         //traversal  
For (var item in O) { alert (item+ ":" +o[item]); }
Popup Properties and Values
alert (o.propertyname);
}); </script>


Onchange= "Window.alert (' triggering events, handling things ')"

Onkeypress= "if (event.keycode==13) {Window.alert (' trigger event, handle things '); return false;}" Enter trigger event and process

Note: The return false must be added to the onkeypress event, and the statement avoids the loss of input entries.

Input _ text box enter or lose cursor trigger event

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.