1. The first JavaScript
JavaScript is the programming language for the Web.
JavaScript is a lightweight programming language.
JavaScript is programming code that can be inserted into HTML pages.
JavaScript, once inserted into an HTML page, can be executed by all modern browsers.
Why learn JavaScript??
HTML
Defines theContent of web pageCSS
Describes thePage layoutJavaScript
Control of theBehavior of web pages
2. Two uses of JavaScript:
The first: js is written in our script tag
Usually we write it above the body closing tag
<script></script>
Copy the code
Second: external reference JS files
<script src=""></script>
Copy the code
3. Three JavaScript printing methods:
Print in a web page
Document. The write (” “);
Note: Strings with tag structures can be parsed
document.write("Hello World!!");
Copy the code
You can also print HTML tags
document.write("
I'm the first div tag to print
");
document.write("
I am a nested paragraph
");
Copy the code
Print in the console
The console. The log (” “);
Note: Tag structured strings cannot be parsed
console.log("Hello World!!!");
Copy the code
Other functions can also be printed:
Print information:
console.info("info");
Copy the code
Typo:
console.error("error");
Copy the code
Print warning:
console.warn("warn");
Copy the code
Popup window
Alert (” “);
Note:Unresolvable The tag structurethestring
willDue to the codetheblockingonlyWhen I hit OKcodeBefore the execution continues
alert("Windows");
Copy the code
Tip: In later learning, type more code, use console.log(” “); This will be very helpful for learning JavaScript!!