Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>JS Bin</title>
  </head>
  <body>
    <div class="box"></div>
    
    <p>Hover over the box </p>
    <script src="https://code.jquery.com/jquery-3.1.0.js"></script>
  </body>
</html>
 
.box {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  background-color: blue;
}
.red {
  background-color: red;
}
button {
  margin-top: 10px;
}
 
$(() => {
  // listen for .hover() event on .box
  $('.box').hover(
    (event) => {
     // 1st handler function 
     // add .red class on hover 
     $(event.currentTarget).addClass('red')
   }, 
   (event) => {
     // 2nd handler function 
     // remove .red class when hover is exited
     $(event.currentTarget).removeClass('red')
   })
})
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x