Home > Web Front-end > JS Tutorial > body text

js triggers select onchange event code_javascript skills

WBOY
Release: 2016-05-16 16:54:52
Original
1310 people have browsed it

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>

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template