HTML input box hint/set disable/Auto get focus __html

Source: Internet
Author: User

There are a lot of ways to set the contents of input boxes, and here are two simpler and more practical methods.

Method One:
<input type= "text" value= "search" onfocus= "this.value=" "onblur=" if (this.value== ') {this.value= ' search '} '/>
Method Two: <input type= "text" placeholder= "search"/> Some browsers do not support
Of course, can also write JS to achieve, here is not an example. Because both of these methods can achieve the basic hint effect.

Set input input box disabled the following are also listed in three ways.

Method One:

disable= "Disable" or add the Disable property directly to set it.

Sex: <input type= "text" name= "lname" disabled= "Disabled" placeholder= "was set disabled"/>

Sex: <input type= "text" name= "lname" Disabled placeholder= "was set disabled"/> Effect

Method Two:

The ReadOnly property can also achieve the above effect, for disable is different when the former is read-only state

Method Three:

Let the mouse not get focus

<input type= "text" value= "is set to disable" onfocus= "This.blur ()" >

The Autofocus property can be used to set the input input box to automatically get focus.

<input type= "text" placeholder= "Automatically get Focus" autofocus>


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.