Recommended learning:In HTML, you can use javascript in the script tag, just add the "<script>JavaScript代码</script>" code to the page. The script tag is used to define client scripts. This element can either contain script statements or point to it through the src attribute. version, Dell G3 computer.
html video tutorial
1. Use the script element
<script> //JavaScript代码 </script>
HTML 4.01 defines 6 attributes for <script><a href="https://www.php.cn/course/list/11.html" target="_blank"></a></p>async (optional) <h4 id="1使用script元素"> indicates that the script should be downloaded immediately, but does not hinder other operations on the page, such as downloading other resources or other scripts to be loaded. Only valid for external script files </h4><p></p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false;">//异步脚本 <script type="text/javascript" defer="defer" src="first.js"></script> <script type="text/javascript" defer="defer" src="second.js"></script> //指定async属性的目的是不让页面等待这两个脚本下载和执行,从而异步加载页面其他内容。 //但是不保证它们的先后顺序,也就是第二个脚本可能在第一个脚本之前执行。</pre><div class="contentsignin">Copy after login</div></div><ul><li><p>charset (optional, rarely used) </p> Specifies the character value of the code, most browsers will Ignore, rarely used </li></ul><ul><li>#defer (optional) <p> indicates that the script can be delayed until the document is completely parsed and displayed. Only valid for external files. <br/></p></li><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false;">//延迟脚本 <script type="text/javascript" defer="defer" src="first.js"></script> <script type="text/javascript" defer="defer" src="second.js"></script> //添加defer属性之后,直到遇到</html>才会执行,也就是最后最后执行就是它了</pre><div class="contentsignin">Copy after login</div></div><li><p><br/>language (obsolete) </p> Used to indicate the programming language used to write code, obsolete</li></ul><ul><li>src (optional) <p> Represents the external file containing the code to be executed <br/></p></li><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false;"><script type="text/javascript" src="first.js"></script> //外部文件first.js将被加载到当前页面中 //注意注意呀,此时在<script>和</script>之间不再包含额外的JavaScript代码,因为这些额外的代码将会被忽略,不执行!!!</pre><div class="contentsignin">Copy after login</div></div><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false;"><script type="javascript" src="www.somewhere.com/file.ja"></script> //也就是说src还可以包含来自外部域的.js文件,而不仅仅是自己编写的。功能更加强大。 //注意注意呀,外部域的.js文件可能不可控,所以要么你是它的所有者、要么他的所有者值得信赖、要么就不要使用!!!</pre><div class="contentsignin">Copy after login</div></div><li><p><br/>type (optional) </p> can be regarded as language Substitutes, commonly used are type=text/javascript, which do not have to be </li></ul>Included in <script></script> will be explained from top to bottom. No other content on the page will be loaded and displayed until all code inside the interpreted