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