Home > Web Front-end > Front-end Q&A > How to call js function in html

How to call js function in html

藏色散人
Release: 2023-01-06 11:15:32
Original
18010 people have browsed it

htmlMethods to call js functions: 1. Call with the control itself; 2. Execute regularly through the time control in javascript; 3. Call through getElementById; 4. Call through document.getElementsByName.

How to call js function in html

The operating environment of this article: Windows 7 system, html5&&javascript version 1.8.5, DELL G3 computer

There are many ways to call js functions in html:

1. You can use the control itself;

For example, <input type="text" onchange="javascript:guest();">

2. Scheduled execution through the time control in javascript;

3. getElementById actually gets an object (element) in a web page and retrieves it by ID.

<input id="guest" type="text" onchange="javascript:guest();">
document.getElementById("guest")语句到<input>;
document.getElementById("guest").value="dddddd";
Copy after login

Assign "dddddd" to ;

4.document.getElementsByName

document.getElementsByTagName

document.getElementsByTagNameNS

also retrieves elements in web pages, but through different retrieval methods, such as name, TagName, etc.

Recommended learning: "HTML video tutorial" "javascript advanced tutorial"

The above is the detailed content of How to call js function in html. For more information, please follow other related articles on the PHP Chinese website!

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