Javascript Form How to - Change text color when having focus








Question

We would like to know how to change text color when having focus.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
input:focus::-webkit-input-placeholder {
  color: #fb0;
}<!-- w  ww . j  ava 2 s. c  om-->
</style>
</head>
<body>
  <input type="text" name="input" placeholder="This is a placeholder" />
</body>
</html>

The code above is rendered as follows: