HTML Form How to - Hover to change button color








Question

We would like to know how to hover to change button color.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img:hover+button {<!-- w ww .ja va  2  s. com-->
  color: red
}
</style>
</head>
<body>
  <img
    src="http://www.java2s.com/style/download.png"
    alt="">
  <button>button</button>
</body>
</html>

The code above is rendered as follows: