Web Development

How to change textBox’s background color when you start to typing into textBox in JavaScript

It’s very simple. We see a lots of website in where, when we try to start type something in textBox then it changes it’s background color. It’s really simple in JavaScript. Let see !

  • First, you add a HTML input control which’s type is text. Set style background color suppose Gray. Then add onclick=change()
<input id="Text1" type="text" style="background-color:Gray;" onfocus="change();" />
  • Then add a JavaScript function
function change(){
   document.getElementById("Text1").style.backgroundColor="silver";
}

Then, try yourself.

Advertisements

5 thoughts on “How to change textBox’s background color when you start to typing into textBox in JavaScript

  1. I am not positive if this is the right spot, but I thought you should know I saw this post awhile ago on a different site. I think it might have been a wordpress blog with a similar title. The content was almost the same, but I noticed that this one here has an older date. I reckon they grabbed it from you, but maybe not who knows. Thought you may want to know.

  2. I have built a blog and I was thinking of changing the template.I got some ideas from here! Feel free to visit my blog and suggest things!

  3. I have built a blog and I am trying to find a new template.Yours looks pretty decent! Feel free to visit my blog and suggest things!

  4. Hi, i think that i saw you visited my blog so here i am!.I am looking for ways to add things to my website!I suppose its ok to use some of your ideas!!

  5. Pingback: free ipad facebook

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s