HTML Form How to - Show textarea when textfield got focus








Question

We would like to know how to show textarea when textfield got focus.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
textarea {<!--from ww w.j  a  v  a 2  s  .  c om-->
  display: none;
}

input[type=text]:focus+textarea {
  display: block;
}
</style>
</head>
<body>
  <input type="text" />
  <textarea></textarea>
</body>
</html>

The code above is rendered as follows: