Friday 28 December 2012

on mouseover counting

move your mouse
move your mouse

Code goes here :




<!DOCTYPE html>
<html>
<head>
  <style>
div.out { width:20%; height:120px; margin:0 15px;
          background-color:#D6EDFC; float:left; }
div.in {  width:50%; height:40%;
          background-color:#FFCC00; margin:10px auto; }
p { line-height:1em; margin:0; padding:0; }
</style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
 <p>code goes here :</p>
<div class="out overout">
  <span>move your mouse</span>
  <div class="in">
  </div>
</div>

<div class="out enterleave">
  <span>move your mouse</span>
  <div class="in">
  </div>
</div>

<script>
  var i = 0;
  $("div.overout").mouseover(function() {
    i += 1;
    $(this).find("span").text( "mouse over x " + i );
  }).mouseout(function(){
    $(this).find("span").text("mouse out ");
  });

  var n = 0;
  $("div.enterleave").mouseenter(function() {
    n += 1;
    $(this).find("span").text( "mouse enter x " + n );
  }).mouseleave(function() {
    $(this).find("span").text("mouse leave");
  });

</script>

</body>
</html>

No comments:

Post a Comment

Do you think it could be useful for you? Share your thoughts with us!