JS Learning notes--imitation mobile phone to send content interaction

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.