Basic application of javascript embedded and external linksThe js language can be completely placed in the html language But depending on the situation, it can be divided into embedded and external links. When there is less js code, you can directly use the embedded method to introduce javascript through the <script></script> tag and related attributes <!DOCTYPE html> <html> <script> document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); </script> <body> </body> </html> However, in large projects and when there are a lot of javascript codes, you need to use external links. When using external links, you need to create a new .js file first <!DOCTYPE html> <html> <script type="text/javascript" src="1245.js"> </script> <body> </body> </html> Put the javascript code you need to write in the 1245.js file Three ways to write JavaScript: inline, embedded, and externally linked1. InlineIn the attributes of the HTML tag, the execution is triggered by the behavior. (Rarely used) 2. EmbeddedWrap it in the HTML file using a script tag and it will execute automatically when the page is opened. (It’s easy to use, but don’t use it with large amounts of JS code.) 3. External linkWritten in a separate js file, introduced in the html file using the src attribute of the script tag, it will be automatically executed when the page is opened. (Recommended because there are various optimization methods) Note : It is rarely used in the industry, almost never used. Inline and external links cannot share the same script tag. In principle, the script tag of the external link can be placed anywhere. The script attribute of the external link is src , not href, not href, not href... The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: What is flex and a detailed tutorial on flex layout syntax
>>: Two ways to solve the problem of MySQL master-slave database not being synchronized
Original derivative command: bin/sqoop import -co...
SQL paging query:background In the company's ...
First of all, we need to know what a state manage...
This article example shares the specific code for...
The current requirement is: there is a file uploa...
1. left(name,4) intercepts the 4 characters on th...
Table of contents 1. Boolean 2. Expression 3. Mul...
Preface The project has requirements for charts, ...
As you build and scale your Django applications, ...
Preface An index is a data structure that sorts o...
Table of contents 1. Unzip 2. Create a data folde...
Tab selection cards are used very frequently on r...
Adding the right VS Code extension to Visual Stud...
This article shares the specific code of js canva...
Hello everyone! I am Mr. Tony who only talks abou...