Changing textbox background color

M

mr_burns

Hi there,

How do I change the background color of a textbox when it is clicked on? Cheers

Burnsy
 
D

David Dorward

mr_burns said:
How do I change the background color of a textbox when it is clicked on?

With CSS.

input[type=text]:focus { background-color: blue; } (needs a modern web
browser).

You could also play with the onfocus and onblur events and set
this.style.backgroundColour using JavaScript.
 
D

Daniel Kirsch

mr_burns said:
How do I change the background color of a textbox when it is clicked on?

<input type="text" onfocus="this.className+=' focused'"
onblur="this.className=this.className.replace(/\s?focused/g,'')">

and some css:

input.focused {
background-color:#ffe;
}

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top