Tips for js to trigger selectonchange events _ javascript skills

Source: Internet
Author: User
To trigger the onchange event of select or text, you must manually change the value of select or text, there is a good way to trigger the selectonchange event select or text onchange event through js. You need to manually (input through the keyboard) change the value of select or text to trigger the event, if you assign values to select or text in js, The onchang event cannot be triggered,
For example, after loading the page, you need to trigger an onChange event and use document. getElementById ("province "). value = "Hubei"; it is not acceptable to assign values to select or text directly. to manually trigger the onchange event, add the following statement after js assigns values to select.

Document. getElementById ("province"). fireEvent ('onchange') to implement,

 Untitled document
Related Article

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.