JavaScript Summary (Ultimate Grand Summary) __javascript
Source: Internet
Author: User
Javascript
. JavaScript basic syntax
. Window objects and their objects
. BOM Programming
. DOM Programming
. JavaScript and CSS Interaction
. Form Validation
. cascading Drop-down Boxes
. JSON data format
. Object-Oriented JS
I. JavaScript syntax basics: (strictly case sensitive)
1.JavaScript (basic syntax, variables, statement control, arrays, functions, etc.)
If writing a JavaScript function does not work and the function name is generally incorrect for a program statement, for example
= = or less ban La (
Bom
Dom
2.<script> nested in File
Import the external JS
The basic syntax of 3.JavaScript
3.1 Data types, variables
Numeric type number
string-type String
Boolean Boolean type
Undefined not declared
Null type
Object type
declaring variables through Var
typeof (variable name) can view type
3.2 Basic operators are similar to the Java language
3.3 Control statements are similar to the Java language
Conditional structure
Loop structure
3.4 Common functions:
alert (content); pop-up box
Prompt input Box
parseint
Parsefloat
isNaN () to determine if it is not a digital
Custom functions
function (Parameters) {
The passed parameter can also be a function
}//in fact, for JS, function declaration without parameters,
Parameters can also be passed when called
Parameters are not necessarily passed parameters
For these special cases you can access the parameters via the argument array
parameter of a function can also pass a function
Cases:
function f (SSS) {
Example:
var s = promet ("Please enter a number:");/input is considered a string
Alert (s+ "100");//concatenation of strings
var a = parseint (s);//
alert (a+100);
Alert (isNaN (a));//is the number returned false not the number returns true
6.window objects Common Properties and methods
window. can be omitted
Common Properties: Screen,documet,history,location
Common methods: Aert (), Comfirm,prompt,open,
Close () IE cannot be used in Firefox that closes the current window
SetTime (function, time);
SetTimeout ("F ()", 3000)//delay 3 seconds off with F () function
Example: [
<script type= "Text/javascript" >
function f () {
Alert ("Helo");
}
SetTimeout ("F ()", 5000);
</script>
]
Setinteval (function, time) call function once every few times
Date object: Finish clock
Put the time in the text box, always refresh
JavaScript scripts can prevent the body from ending before
This also helps to improve efficiency
Events: OnLoad Events
Example:
var date = new Date ();
var year = Date.getyear () +1900;
var month = Date.getmonth () +1;
document.write (year+ "," +month+ "," +date.getdate ());
document.write ("<br>");
var hours = date.gethours ();
var minutes = date.getminutes ();
var seconds = date.getseconds ();
document.write (hours+ ":" +minutes+ ":" +seconds);
Open a Window
window.open ("damel1.html");
You can also set the open window:
window.open ("damel1.html", "My Window", "Width=400,height=350,status=yes,resizable=yes");
Yes can also be replaced with 1
6.DOM programming: Look at the elements in the browser as objects
A.document
Document property access way to access form elements
getElementById ("ID name") Access based on ID
Getelementsbyname ("name") access based on name, get an array
getElementsByTagName ("tag name") is accessed according to the label to get an array
var inputs = document.getElementsByTagName ("input");
alert (inputs.length);
for (var i = 0;i<inputs.length;i++) {
alert (Inputs[i].type);
}
B.history
Go (1)/forward (), Go ( -1)/goback ()
<a href= "Javascript:history.go ( -1)" > Back </a>
<a href= "Javascript:history.go (1)" > Forward </a>
C.location
Location.href= "Go to the page"
Location.reload
D. Change the hyperlink
E. Select All and select All
D. Display and concealment of layers
7,string Array
7.1string//on the validation of regular expressions
var str = "DDD";
var st = new String ("ddd");
var s = new Array (1,2,3,4,5);
var array = new Arry (3);//This parameter does not have a limit effect
Array[0] = 1;
ARRAY[1] = 2;
array[2]=3;
ARRAY[4] =4;//is also correct, JS not so strict
13. Summary: The basic grammar is over
Very cool effect, are written by JS
Many effects are commonly used, there is a third write some JS
function library for everyone to use. The more popular jquery
Extjs,jqueryui (continue to enrich the library of functions on the basis of jquery)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service