Javascript Basics Tutorial: How to Insert JavaScript Code
How to write JavaScript code in HTML
Use the .
is the text type (text). JavaScript is to tell the browser that the text inside belongs to JavaScript language.
The above code is where we insert javascript code into the html page
Let’s take a look, there is another way to use javascript
Usually we are used to it Call javascript js
Now we have an html file that needs to use js code, but I don’t want to insert the js code into the html, so there will be a lot of code. Usually in this case, we have to create A separate js file, so that if we want to use js code in our html code, we need to introduce this js file:
Next we output a sentence in demo.js, first create this file
Then we introduce js code into the html code
The format is as follows:
src is the address of this file, so we need to write the path correctly. If the path is incorrect, it means that the js code has not been introduced and cannot be used.