Learn JS notes----Record The learning points in class, share what the teacher teaches:
1.html Content
<DivID= "box"> <DivID= "message"> <!--<p class= "left" > <span> This is the first sentence </span> &L t;/p> <p class= "right" > <span> This is the second sentence this is the second sentence. Lt;/span> </p> - </Div> <imgID= "Small-pic"src= "Img/150.jpg" /> <inputID= "Text1"type= "text" /> <inputID= "BTN1"type= "button"value= "Submit" /> <StrongID= "txt">0</Strong> <aclass= "Active"href= "javascript:;"ID= "Up">On</a> <ahref= "javascript:;"ID= "Down">Under</a></Div>
2.JS effect
<script>varOdiv = document.getElementById (' message '));varoimg = document.getElementById (' small-pic '));varOtext = document.getElementById (' Text1 '));varOBTN = document.getElementById (' btn1 '));varAUp = document.getElementById ("Up");varAdown = document.getElementById ("Down");varOtxt = document.getElementById ("TXT");varONOFF =true;varDIR =true;varnum = 0; Odiv.onclick=function() {odiv.innerhtml= ' '; Otxt.innerhtml= 0; Num= 0;} Oimg.onclick=function () { if(onOff) {oimg.src= ' Img/151.jpg '; OnOff=false; } Else{oimg.src= ' Img/150.jpg '; OnOff=true; }};aup.onclick=function() {aup.classname= ' Active '; Adown.classname= ' '; Dir=true;} Adown.onclick=function() {aup.classname= ' '; Adown.classname= ' Active '; Dir=false; }obtn.onclick=function () { if(Otext.value = = ") {//the input value is an empty bullet boxAlert (' Please enter content '); } Else { //alert (ONOFF); true = ' Left ' //alert (ONOFF); false = ' Right ' varSclass = ' '; if(onOff) {Sclass= ' Left '; } Else{Sclass= ' Right '; } if(dir) {//add content on topodiv.innerhtml = ' <p class= ' + sclass + ' "> ' + ' ' + ' <span> ' + otext.value + ' </span> ' + ' </p> ' +odiv.innerhtml; }Else{//add content in the nextodiv.innerhtml + = ' <p class= "' + Sclass + '" > ' + ' ' + ' <span> ' + otext.value + ' </span> ' + ' </p> ' ; } otext.value= ";//input value is empty at commitNum++//number with submission +1otxt.innerhtml =num; } };</script>
3. Display