Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  113] [ 4]  / answers: 1 / hits: 26080  / 15 Years ago, thu, july 16, 2009, 12:00:00

What I want to do is display an input field with the text color black.


Then when the person clicks inside the input field (onfocus) I want to change the text color to red.


Then, when the person click outside of the input field (no longer focus), I want to change the text color back to black.


I know how to handle the JavaScript onfocus event using the following:


<input ctype="text" onfocus="this.style.color='red';" />

But how do I handle the "off focus" to change the text color back to black?


More From » html

 Answers
6

try using onblur, it is called when an element loses focus.


[#99117] Sunday, July 12, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
chauncey

Total Points: 377
Total Questions: 91
Total Answers: 99

Location: Jordan
Member since Thu, Aug 5, 2021
3 Years ago
;