Home > Web Front-end > HTML Tutorial > What are the methods for calling js in html?

What are the methods for calling js in html?

coldplay.xixi
Release: 2021-04-27 15:14:44
Original
11567 people have browsed it

html calls the js method: 1. Click to call JavaScript, the code is [$(document).click(function ()]; 2. Call JavaScript directly, the code is [$(document).ready(function () )】.

What are the methods for calling js in html?

The operating environment of this tutorial: windows7 system, html5 version, DELL G3 computer.

html calls the js method:

1. Click to call JavaScript:

<button onclick="loadXMLDoc()">button</button>
<script>
    $(document).click(function () {
        loadXMLDoc();
    });
    function loadXMLDoc() {
        // 写实现功能的方法
    }
</script>
Copy after login

2. Call JavaScript directly:

<script type="text/javascript">
    // 加载页面
    $(document).ready(function () {
        loadXMLDoc();
    });
    // 加载方法
    function loadXMLDoc() {
       // 实现方法
      ......
    }
</script>
Copy after login

Related learning recommendations: html video tutorial

The above is the detailed content of What are the methods for calling js 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