javascript for website development


JavaScriptProgramming language:

1.A programming language specifically compiled and executed in the browser

2.Help browsers solve simple needs of users

3.Implementation based on object-oriented and weakly typed syntax

JavaScriptstudy tutorial

Old Du explainedJavaScripttutorial,content coversJavaScriptcore syntax、JavaScriptBuilt-in support classes、JavaScriptdebugging、JavaScript DOMprogramming、JavaScript BOMprogramming、A large number of small front-end cases、JavaScriptevent handling、JavaScriptobject、inherit、JSONother knowledge points。

what's nextJavaScriptThe learning content is the same as the followingjavawebCombined learning tutorials

Basic grammar

one、JavaScriptHow to write commands

(javascript for website development)1.existHTMLin file<script>Write commands internally

2. existjsWriting command format in file【recommend】

two、JavaScriptmedium variable

(javascript for website development)1.variable declaration method: JavaScriptWeakly Typed Programming Language,Therefore, it is forbidden to decorate variables with concrete data types

  • var variable name;
  • var variable name1,variable name2;

2.variable assignment

  • var variable name=value
  • var variable name;
  • variable name=value;

3.variable name naming convention

1)Variable names can only have letters,number,underscore, Dollar sign($)

2) Variable name cannot start with a number

3) can not be usedJavaScriptkeywords as variable names var var=10; error

three、JavaScriptMedium data type


1)basic data type

2) Advanced Reference Data Types

2. basic data type

1) numberTypes of:Number type,integer,single precision,Double precision isnumberTypes of

2) stringTypes of: String type,Strings can be enclosed in either a pair of double quotes or a pair of single quotes "abc" 'abc'

3) booleanTypes of: boolean type valuetrue/false

3.Advanced Reference Data Types

1) functionTypes of:function type.equivalent toJavamiddleMethodTypes of。OnefunctionType objects are used to manage a function

(javascript for website development)2) objectTypes of: existJavaScriptAll objects generated by constructors in theobject

4. The relationship between variables and data types:

JavaScriptDetermine the data type of the variable according to the content of the variable assignment

Four、JavaScriptspecial value in

1. undefined:javascriptWhen the variable is not assigned,Its default value isundefined。

At this time, the variable data type is alsoundefined

2.NaN: represents an illegal number。At this point the variable data type isnumber

3.Infinity:represents an infinite number.At this point the variable data type isnumber

4.null:Indicates that the current object points to an empty memory,But empty memory cannot store data

At this point the object data type isobject

Fives、JavaScriptControl Statements and Loop Statements

1.andJavaControl statement and loop statement syntax is exactly the same

2.control statement if ,switch

3.loop statement for while,do..while

six、JavaScriptmedium array

1.JavaScriptThe medium array is equivalent toJavamiddleListgather

(javascript for website development)2.JavaScriptThe array can store any type of data at a time

3.JavaScriptThe number of control memory in the array can be changed at will

seven、JavaScriptmiddle function

1.function declaration format

function Function name(parameter name,parameter name){

(javascript for website development)

Command Line;

eturn return value


1) when the function is declared,must usefunctionretouch to retouch

2) when the function is declared,Forbid specifying return data type

3)when the function is declared, A formal parameter can only specify a name,but cannot specify data type,also cannot be usedvarretouch

(javascript for website development)4)when the function is declared,able to passreturnSpecify return data。

2.function call:


***windowProperties and functions in objects are called when they are called,can not writewindow


one、JavaScriptmiddledomobject withdocumentobject


1) domobject:document Object model;document model object

2) Onedomobject is used to manage aHTMLLabel

(javascript for website development)3)Each time the browser loads oneHTMLwhen labeling,automatically for thisHTMLlabel generates aDOMobject


1)documentobject document object

2) browser according tohtmlLabel declaration order is stored in memory as a tree structureDOMobject.

3) documentObjects are generated by the browser 。only one browserdocumentobject

4)documentObjects are responsible for targeting based on targeting criteriadomobject

two、domObject positioning method:

1.According to the labelIdattribute targeting associatedDOMobject

(javascript for website development)var domObj = document.getElementById("idAttributes")

2.According to the labelnameattribute targeting associatedDOMobject

var domArray =

3.Locate associated tags based on tag typeDOMobject

var domArray =
document.getElementsByTagName("label type")

three、domobject-to-tag management:

(javascript for website development)1.domobject role:It is used to assign and get values to the attributes in the managed tags

2.domobject management tabvalueAttributes:

var num = dom.value; //read

dom.value = num; //assign

3.domObject Management Tag Status Properties

(javascript for website development)checkedYesboolean checked=true means selected,checked=false means not selected

4.domObject management dual-target label prompt information


var num = dom.innerText;

(javascript for website development)5.domStyle properties for object management tags

(javascript for website development)

var num = attribute name

Four、listen event

1. introduce:

1)HTMLA set of attributes in a tag

2)Monitor when and how the user operates the current tab。When monitoring behavior occurs。

(javascript for website development)监听事件通知浏览器调用javascriptListening event notification browser call



2) Classification---Monitor users use mouse action labels

3.Monitor users use keyboard operation tags

1)onkeydown: 监听用户在何时在当前Keyboard listening event上按下键盘

(javascript for website development)




2) onblur:监听用户何时使用鼠标让当前标签丢失光标

3)onfocus:Keyboard listening event

(javascript for website development)4) onmouseover:监听用户何时使用鼠标悬停在标签上方

5) onmouseout:Monitor users press the keyboard when on the current label