Home  >  Article  >  Web Front-end  >  js triggers select onchange event code_javascript skills

js triggers select onchange event code_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:54:521311browse

The onchange event of select or text needs to be triggered manually (via keyboard input) by changing the value of select or text. If you assign a value to select or text in js, the onchang event cannot be triggered.
For example, after the page is loaded, you need To trigger an onChange event, use document.getElementById("province").value="Hubei" in js; it is not possible to directly assign a value to select or text. If you want to manually trigger the onchange event, you need to assign a value to select in js. Add the following statement

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

Copy code The code is as follows:



Untitled Document



Province:
City:
< /body>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn