The juery text box gets the focus and loses the focus. It processes the text content.

Source: Internet
Author: User
Usage: Enter the default value of the prompt in the text box. Also, when editing, the changed value is displayed, and the previous value is not displayed. You can also set the CSS style when adding verification: view Code 1 <style type = "text/css">
2 body
3 {
4 font: normal 12px/17px Arial;
5}
6 div
7 {
8 padding: 2px;
9 width: 240px;
10}
11 input, textarea
12 {
13 width: 12em;
14 border: 1px solid # FFDEAD;
15}
16. focus
17 {
18 border: 1px solid # f00;
19 background: # F5FFFA;
20}
21 </style>
22
23

Jquery code:

View Code 1 $ (function (){
2 $ (": input"). bind ("focus", function (){
3 $ (this). addClass ("focus ");
4 if ($ (this). val () = this. defaultValue ){
5 $ (this). val ("");
6}
7 });
8 $ (": input"). bind ("blur", function (){
9 $ (this). removeClass ("focus ");
10 if ($ (this). val () = ''){
11 $ (this). val (this. defaultValue );
12}
13 });
14 });

 

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