2015.12.1 built-in objects in JavaScript
Review:
1, JS in the built-in function
Alert Prompt Write parseint parsefloat eval isNaN document getElementById getelementbyname value InnerText InnerHTML lengt H Join Sort
eval (); var result = eval (); var a= "2+3" eval ("result=" +a); there will be Eval and the JSON the combined use of
IsNaN (); is not the number
2. JS event
Click event onclick onload onchange bgColor document
Location href onfocus onblur This(the label itself as an object, use this in the function to get the corresponding element of the label.) )
Mouse events: Over-out down-upmove this.src
OnSubmit: It doesn't appear on the form's submit button, or it doesn't make any sense. "Pro-Test"
Instead, it appears on the form form, using a false () return of two times to limit the form's submission.
3. Form verification:
Verify that the input label for the text type in the form is empty: There are three forms: we commonly use length==0,as this is most consistent with the sense of Java "I think". Second, there is . value== "". Value==null. altogether three kinds of forms.
Focus ();// Let's set the property of the tag to get focused
Select ();// Select the contents of the previous input box. "Easy to hold one letter for deletion"
by Return false; to prevent the submission
Getelementbyname gets an array;checked false
When verifying a single or multiple box, remember to determine the checked.
4, Regex Regular expression;js in the regular expression as an object, to call the method of the object test
Use the string you want to validate as a parameter to the test method.
The matches method in the String class .
The regular expression is used as a parameter in Java.
The regular expression is used as the object in Js.
5, JS in the built-in objects:
1) Browser Window object
2) Js built-in object
3) Js HTML Tag Object
Getelementsbyname Remember the value inside to give ""
That is:var allpick = document.getelementsbyname ("Allpick") [0].checked;
The following form is not reliable:var allpick = document.getelementsbyname (Allpick) [0].checked;
Select All Counter Selection demo
<Scripttype= "Text/javascript"> functionAllpick () {varAllpick=Document.getelementsbyname ("Allpick")[0].checked; varHobby=Document.getelementsbyname ("Hobby"); if(Allpick) { for(varI=0; I<Hobby.length;i++) {hobby[i].checked=true; } }Else{ for(varI=0; I<Hobby.length;i++) {hobby[i].checked=false; } } } functionCounterpick () {varHobby=Document.getelementsbyname ("Hobby"); for(varI=0; I<Hobby.length;i++){ if(hobby[i].checked) {hobby[i].checked=false; }Else{hobby[i].checked=true; } } } </Script> </Head> <Body>Hobbies:<inputtype= "checkbox"name= "Hobby"value= "0" />Basketball<inputtype= "checkbox"name= "Hobby"value= "0" />Basketball<inputtype= "checkbox"name= "Hobby"value= "0" />Basketball<inputtype= "checkbox"name= "Hobby"value= "0" />Basketball<inputtype= "checkbox"name= "Hobby"value= "0" />Basketball<inputtype= "checkbox"name= "Hobby"value= "0" />Basketball<HR/>Select all:<inputtype= "checkbox"name= "Allpick"onclick= "Allpick ()"/> <inputtype= "button"name= "Counterpick"value= "Reverse Selection"onclick= "Counterpick ()"/>
Built-in objects in JavaScript