The method description of JS triggering onchange event

Source: Internet
Author: User

How to trigger the onchange event of TextBox control through code in JS code mode, after checking the data, find JS provides a method, can trigger the control should be all events

The onchange event in JS is an event that changes the value of the input control at the client, such as a TextBox.   However, if you change the value of a textbox in the JS code, instead of changing a TextBox value via keyboard input, you will not start onchange events. Then, how in the JS code mode to trigger the TextBox control onchange event, after consulting data, found that JS provides a method, can trigger the control should be all events.   The Object.fireevent () method, which uses methods such as Object.fireevent (' onchange '), triggers the control's onchange event.   Similarly, using the FireEvent method in JS can also trigger other space events.    • Add that the above FireEvent method is not supported in Firefox browsers, so if you want to run both IE and FF, try the following code.   The code is as follows: if (obj.fireevent) {obj.fireevent (' onchange ');} else {obj.onchange ();} That is, to determine whether the FireEvent event is available or not, use the onchange () method directly.

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.