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

js triggers select onchange event code_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:54:52
Original
1361 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
Latest Issues
AngularJS Select default value?
From 1970-01-01 08:00:00
0
0
0
Select option using PHP loop
From 1970-01-01 08:00:00
0
0
0
Chrome doesn't apply padding to select options
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template