JavaScript - Getting Started Usage

JavaScript  Usage


HTML scripts must be located between the <script> and </ script> tag.

The script may be placed in an HTML page <body> and <head> section.

<Script> tag

To insert JavaScript in the HTML page, use the <script> tag.

<Script> and </ script> JavaScript will tell where to begin and end.

The lines between the <script> and </ script> contains JavaScript:

<Script> 
Alert ( "My first JavaScript" );
 </ Script>

<Body> in JavaScript

In this example, JavaScript will write the text to the HTML <body> when the page loads:

<! DOCTYPE HTML> 
<HTML> 
<head> 
<Meta charset = "UTF-. 8"> 
<title> novice tutorial (runoob.com) </ title> 
</ head> 
<body> 
    
<P> 
the JavaScript capable of directly writing HTML output stream:
 </ P> 
<Script> 
document.write ( "<h1 of> this is a header </ h1 of>" ); 
document.write ( "<P> this is a paragraph </ P>." ) ;
 </ Script> 
<P> 
You can use only HTML output stream <strong> document.write </ strong>
 . If you use it after the document has loaded (for example, in a function), will cover the entire document.
</ P> 
    
</ body> 
</ HTML>

 

Guess you like

Origin www.cnblogs.com/gengyufei/p/12590878.html