UpTest > Web Development Internet Programming > DHTML Test

Test: DHTML Test

Question 33: Prev Next
This is a JavaScript function for changing the color of the text box named "txtName":

function SetColor(col)
{ document.forms[0].txtName.style.background=col }

How will you change the color of the text box txtName to green, only for the time that the user is pressing any key?
<input type="text" onkeydown="SetColor('white')" onkeyup="SetColor('green')" name="txtName">
<input type="text" onkeydown="SetColor('green')" onkeyup="SetColor('white')" name="txtName">
<input type="text" onkeydown="SetColor('green')" name="txtName">
<input type="text" onkeydown="SetColor('white')" name="txtName">

Please login to submit your answer.