Small examples of jquery events

Source: Internet
Author: User

User name grayed out

1 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en">2 <HTML>3   <Head>4     <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">5     <styletype= "Text/css">6 . MyClass{7 Color:#c0c0c08         }9     </style>Ten   <Scripttype= "Text/javascript"src=".. /js/jquery-1.6.js "></Script></Head> One   <Body> A     <TableBorder= "1"Align= "Center"> -         <TR> -             <th>User name</th> the             <TD> -                 <inputtype= "text"value= "Enter user name"/> -             </TD> -         </TR> +     </Table> -     <Scripttype= "Text/javascript"> +     $(function(){ A         $("input"). addclass ("MyClass"); at         $("input"). Focus (function(){ -             $( This). Removeclass ("MyClass"); -             $( This). Val (""); -         }) -     }); -     </Script>     in   </Body> - </HTML>

Tanks move up and down.

1 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en">2 <HTML>3   <Head>4     <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">5     <Scripttype= "Text/javascript"src=".. /js/jquery-1.8.2.js "></Script>6   </Head>7   <Body>8     <imgsrc=".. /images/zgl.jpg "/>9     <Scripttype= "Text/javascript">Ten         //Initialize One         $(function(){ A             //position Picture -             var$img= $("img"); -             //Position the picture at the specified location the $img. Offset ({top: $, left: -}); - $img. Width ( -); - $img. Height ( $); -             //add an event to a picture + $ (document). KeyDown (function(){ -                 //get the code code for the button +                 varCode=Event.keycode; A                 //Judging at                 if(Code==  -){//on - $img. Offset ({top:y-= the}); -                 }Else if(Code==  +){//under - $img. Offset ({top:y+= the}); -                 }Else if(Code== Panax Notoginseng ){//left - $img. Offset ({left:x-= the}); in                 }Else if(Code==  the){//Right - $img. Offset ({left:x+= the}); to                 } +             }); -         }); the         //Global Variables *         vary=  $; $         varx=  -;Panax Notoginseng     </Script> -   </Body> the </HTML>

Related Article

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: 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.