MouseOut vs MouseLeave

by freedawirl

HTML

<div class="out overout">
  <p>move your mouse</p>
  <div class="in overout">
    <p>move your mouse</p>
    <p>0</p>
  </div>
  <p>0</p>
</div>
<div class="out enterleave">
  <p>move your mouse</p>
  <div class="in enterleave">
    <p>move your mouse</p>
    <p>0</p>
  </div>
  <p>0</p>
</div>

CSS

div.out {
  width: 40%;
  height: 120px;
  margin: 0 15px;
  background-color: #d6edfc;
  float: left;
}

div.in {
  width: 60%;
  height: 60%;
  background-color: #fc0;
  margin: 10px auto;
}

p {
  line-height: 1em;
  margin: 0;
  padding: 0;
}

JavaScript

var i = 0;
$("div.overout")
  .mouseover(function () {
    $("p:first", this).text("mouse over");
  })
  .mouseout(function () {
    $("p:first", this).text("mouse out");
    $("p:last", this).text(++i);
  });

var n = 0;
$("div.enterleave")
  .mouseenter(function () {
    $("p:first", this).text("mouse enter");
  })
  .mouseleave(function () {
    $("p:first", this).text("mouse leave");
    $("p:last", this).text(++n);
  });