Mailbox Login Interface Placeholder (placeholder) jquery method

Source: Internet
Author: User

We all know that when the mailbox landing when the default state will have a text reminder, when the mouse focus on the mailbox text box, the content text will be emptied.

HTML5 has a placeholder (placeholder) attribute, but compatibility is not particularly good ~ Here's how jquery works

CSS code:

<input type= "text" id= "address" value= "Please enter your email address"/>
<input type= "text" id= "password" value= "Please enter password"/>
<input type= "button" value= "Login"/>

jquery Code:

$ (function () {
$ ("#address"). focus (function () {//Address box gets mouse focus
var txt_value=$ (this). Val (); Get the value of the current text box
if (txt_value==this.defaultvalue) {//Use DefaultValue property
$ (this). Val (""); Empty the contents of the text box if the condition is met
};
});

$ ("#address"). blur (function () {//Address box loses mouse focus
var txt_value=$ (this). Val (); Get the value of the current text box
if (txt_value== "") {
$ (this). Val (This.defaultvalue); If the condition is met, the content is set
};
});

});

Mailbox Login Interface Placeholder (placeholder) jquery method

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.