Javascript Form How to - Remove background image on text input focus








Question

We would like to know how to remove background image on text input focus.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
input[type=text] {<!--   w w  w. ja  va 2  s . com-->
  line-height: 20px;
  font-size: 14px;
  padding: 2px 5px;
  background: url(http://www.java2s.com/style/download.png) repeat-x;
}

input[type=text]:focus {
  background-image: none;
}
</style>
</head>
<body>
  <input type="text">
</body>
</html>

The code above is rendered as follows: