Click on the cell to clear the default value and be able to set the input font color

Source: Internet
Author: User

Click on the cell to clear the default value and be able to set the input font color:

In many cases, the text box has default text, which is usually the text of the prompt class, when you click on the text box to clear the writing text, the following is a brief introduction to how to achieve this effect. The code is as follows:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"> <title>JavaScript convenience Form</title><Scripttype= "Text/javascript">functionTxtfocus (EL) {if(El.defaultvalue==el.value) {El.value= "'; El.style.color= 'Red'; }}functionTxtblur (EL) {if(El.value== "') {El.value=El.defaultvalue; El.style.color= '#000'; }}</Script><Body><inputtype= "text"style= "color: #666;"onfocus= "Txtfocus (this)"onblur= "Txtblur (this)"value= ' Please enter a predetermined person '></Body></HTML>

The above code implements the function we want, when you click on the text box to clear the default value of the text box, the input text will also change color. The code is very simple and is not covered here.

The original address is: http://www.51texiao.cn/javascriptjiaocheng/2015/0507/901.html

The original address is: http://www.softwhy.com/

Click on the cell to clear the default value and be able to set the input font color

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.