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
coldplay.xixiOriginal
2021-04-27 15:14:3111552browse

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>

2. Call JavaScript directly:

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

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!

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