While looking at the advanced JavaScript tutorials for a while ago, I found a lot of basic JavaScript concepts that I didn't understand.
Online Search, see everyone on the "Basic JavaScript Tutorial (8th Edition)" good evaluation, bought a copy .
(US) Tom Negrino Dori Smith Translator: Chen Jian ou Liu Jing Series name: Turing programming series Publisher: People's post and Telecommunications publishing house
After looking at it, I benefited from the decision to recommend this book to JavaScript's introductory shoes.
The reader of this book must have a certain HTML base, because JavaScript basically is the operation of the DOM, so, there is a certain HTML base seems more convenient. The greatest benefit of this book is that it's every line of code, all to do a detailed explanation, it can be said hand-in with the reader to get started.
As an example:
Chapter 2.10, using multistage conditions
Script 2-14 This section of HTML establishes a multilevel condition page
<! DOCTYPE html>
Script 2-15 This conditional statement allows for multiple possibilities to be checked
Window.onload = Initall;function Initall () {document.getElementById ("Lincoln"). onclick = saysomething; document.getElementById ("Kennedy"). onclick = Saysomething;document.getelementbyid ("Nixon"). onclick = saysomething;} function saysomething () {switch (this.id) {case ' Lincoln ': Alert ("Four score and seven years ago ..."); Break;case "Kennedy" : Alert ("Ask not what your country can does for you ..."), Break;case "Nixon": Alert ("I am not a crook!"); Break;default:}}
using the Switch/case statement1. window.load = Initall;
When the page is loaded, call the Initall () function
2. function Initall () {
document.getElementById ("Lincoln"). onclick = saysomething;
document.getElementById ("Kennedy"). onclick = saysomething;
document.getElementById ("Nixon"). onclick = saysomething;
}
In this function, we set the onclick handler for each button on the page. Because the ID property and the Value property are set in HTML, the event handler can be set using getElementById (). If you have the Value property, you can use the getElementById () call, so you do not have to set the ID property.
3. function saysomething () {
This line begins the saysomething () function
4. switch (this.id) {
The ID of the This object is used as a parameter to switch (). This value determines which of the following case statements will be executed.
5. Case ' Lincoln ':
Alert ("Four score and seven years ago ...");
Break
If the ID of this object is Lincoln, then this warning message is realistic. If the user clicks Lincoln, it will enter the code here. But here we have done what we need, so we want to leave this switch statement, so we need to use the break statement. If there is no break, the following code will continue to execute. Although in some cases the continuation of the following branch is the effect we need, it should not be done in this example.
6. Case "Kennedy":
Alert ("Ask not what your country can does for you ...");
Break
If the user clicks Kennedy, the case block is entered.
7. Case "Nixon":
Alert ("I am not a crook!");
Break
Finally, if the user clicks Nixon, it will enter here and another warning dialog box pops up. Then exit the switch statement.
8. Default:
If the user's input does not match the above criteria, then the code will be executed here. That is, if the switch value does not match any case value, it goes into the default section. The default section block is optional, but including the default block is a good programming habit, just in case. In this script, there is no need to execute the code, because we should not be able to enter the default part.
9. }
This right curly brace ends the switch statement.
The above is a small example of the book, the entire example of the book is this look, basically is a line of explanation of the past, it is suitable for new beginners to learn JavaScript students.
This book focuses on the understanding and application of JavaScript, after reading this book, the basic JavaScript statements should be no longer a problem.
Interested students, can go to buy a look at Oh.
JavaScript Primer Book recommended JavaScript Basics Tutorial