JQuery – Mouse Cousor Position Counter
DEMO
With JQuery you can count how many times the mouse pointer enters and exits from a DOM element.
The source code:
<!DOCTYPE html> <html> <!-- Don't Break My b***s - Gimme Code! Project --> <!-- Author: Andrea Tonin - http://blog.lucedigitale.com --> <!-- This code come with absolutely no warranty --> <!-- If you use this code in your project please give a link to http://blog.lucedigitale.com --> <!-- Thanks in advance --> <head> <title></title> <style> div.out { width:40%; height:120px; margin:0 15px; background-color:#D6EDFC; float:left; } div.in { width:60%; height:60%; background-color:#FFCC00; margin:10px auto; } p { line-height:1em; margin:0; padding:0; } </style> <script type="text/javascript" src="js/jquery-2.0.3.js"></script> </head> <body> <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> <script> var i = 0; $("div.overout").mouseout(function(){ $("p:first",this).text("mouse out"); $("p:last",this).text(++i); }).mouseover(function(){ $("p:first",this).text("mouse over"); }); var n = 0; $("div.enterleave").on("mouseenter",function(){ $("p:first",this).text("mouse enter"); }).on("mouseleave",function(){ $("p:first",this).text("mouse leave"); $("p:last",this).text(++n); }); </script> </body> </html>