How to change color when HTML input type text get focus with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>

<head>  
</head>
  
<body>


Enter a string: <input type="text" onfocus="SetColor(this)">


<script>        

function SetColor(i_object) 
{
    i_object.style.background = "wheat";
}

/*
run:
  
When input type text get focus color will change to: "wheat"
    
*/

</script>
</body>
</html>

 



answered Aug 22, 2015 by avibootz
...