Closures: Child functions can use local variables of the parent function
<HTML> <Head> <title>Closed Package</title> <Script> functionaaa () {//Parent Function vara= A; functionBBB () {//A child function closure can refer to a local variable of the parent functionalert (a); } BBB (); } aaa (); </Script> </Head> <Body> </Body></HTML>
Interlaced color
<HTML> <Head> <title>Interlaced color</title> <Script>window.onload=function(){ varALi=document.getElementsByTagName ('Li'); for(varI=0; I<Ali.length;i++){ //I 0 1 2 3 4 5 ... if(i%2==0) {Ali[i].style.background='Grey'; } ElseAli[i].style.background="'; } } </Script> </Head> <Body> <ul> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> </ul> </Body></HTML>
Seconds conversion
<HTML> <Head> <title>Seconds conversion</title> <Script> vars=1137; Alert (parseint (S/60) + ' min ' +s%60+ ' seconds '); </Script> </Head> <Body> </Body></HTML>
Switch statement
<HTML> <Head> <title>Switch statement</title> <Script> varname="Zhang San"; varSex='male'; Switch(Sex) { Case 'male': Alert (name+'Hello, sir. '); Break; Case 'female': Alert (name+'Hello, Madam! '); Break; default: Alert (name+'Hello! ');} </Script> </Head> <Body> </Body></HTML>
Trinocular operator
Conditions? Statement 1: Statement 2
<Script> vara= A;//judging Odd even numbersa%2==0?Alert ("even"): Alert ("Odd"); </Script>
JavaScript Getting started the third day