JavaScript is a scripting language that can be embedded in HTML code that has a browser running, based on event and object driven.
JavaScript is powerful, and the main features of the Web page are the following:
-
Validating forms
-
Web effects
JavaScript is still a lot of content, here we simply introduce the following JavaScript syntax rules.
Data types for JavaScript
String type (single quote multi-quote) numeric (integer, floating-point) Boolean (True False) object
Null value (used to clear the contents of a variable a = null;) undefined (the variable has not been assigned a value)
The use of the keyword VAR for the declaration and assignment of JavaScript variables
var var_name = value;
It is recommended that you declare a variable before you use it to make it easier to troubleshoot errors.
In JavaScript, each statement ends with a semicolon.
JavaScript definition functions
function Func_name (parameter) {
return var;
}
Calling functions
Func_name (); /* Parentheses cannot be omitted */
How JavaScript is embedded in the script
1. Can be embedded directly into the HTML code
<script language= "javascript" >/*language attribute can be omitted by default is javascript*/
JavaScript statements;
</script>
<body> <script> alert ("I am ceo,you son of Bitch"); </script></body>
JavaScript functions usually trigger execution under the corresponding event.
<input type= "Submit" name= "Submit" value= "Check" onclick= "Check ();" >
2. Referencing JavaScript files
<script src= "JS file path" ></script>
You can do this by writing JavaScript code separately into a JavaScript file with JS as the suffix name
Referencing JavaScript files in this way requires attention:
Only JavaScript script code can be included in a JavaScript file and cannot contain <script></script> and HTML code
JavaScript code cannot be included in the <script></script> that references JavaScript scripts.
This article is from the "thick Product Thin Hair" blog, please make sure to keep this source http://joedlut.blog.51cto.com/6570198/1855505
Getting Started with PHP (8) PHP interacts with JavaScript