Day 26th: js-$id function, Focus Event

Source: Internet
Author: User

first, the function return statement
Define the return value of the function, set the return value with return inside the function, and a function can have only one return value . also, terminate the execution of the Code.
All custom functions do not return a value by default
Don't break after Return.

var a=10,b=20,c=30;
++a;
a++;
e=++a+ (++b) + (c + +) +a++;
Alert (e);//77

second, get focus, Lose focus Event
Get focus:onfocus
Lost Focus:onblur

Case:

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title>$id function</title>6     <style>7 Div{8 Height:100px;9 width:100px;Ten Background-color:Pink; one         } a     </style> -     <Script> - window.onload=function(){ the              function  $id (id) {document.getElementById return  (id); + }   - $id ("Demo1"). Style.backgroundcolor="Red"; + $id ("Demo2"). Style.backgroundcolor="Yellow"; - $id ("Demo3"). Style.backgroundcolor="Blue"; +  a $id ("btn"). onclick=function(){ at                 if($id ("txt"). Value=="Deng"){ - Alert ("congratulations, the Jackpot."); -                 }Else{ - Alert ("no such person ."); -                 } -             } in         } -  to     </Script> + </Head> - <Body> the <DivID= "demo1"></Div> * <DivID= "demo2"></Div> $ <DivID= "demo3"></Div>Panax Notoginseng <inputtype= "text"ID= "txt"value= "please Enter ..."> - <ButtonID= "btn">Inquire</Button> the </Body> + </HTML>

Operating Effect:

Day 26th: js-$id function, Focus Event

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.