Home  >  Article  >  Web Front-end  >  How to call js function in html

How to call js function in html

藏色散人
藏色散人Original
2021-05-26 11:41:2617980browse

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, 00e505620a4cf191e5739153fbe1e795

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";

Assign "dddddd" to d5fd7aea971a85678ba271703566ebfd;

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!

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