Home >Web Front-end >HTML Tutorial >What are the methods for calling js in html?
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 () )】.
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!