Javascript Form How to - Hover to change button text








Question

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

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='/js/lib/mootools-core-1.4.5-nocompat.js'></script>
<style type='text/css'>
button {<!-- w ww  .jav a  2 s  .c  o  m-->
  width: 6em
}

button:hover span {
  display: none
}

button:hover:before {
  content: "Reply!"
}
</style>

</head>
<body>
  <button>
    <span>3 replies</span>
  </button>
</body>
</html>

The code above is rendered as follows: