Copy Code code as follows:
<script src= "Jquery.js" ></script>
<script>
(function ($) {
$.fn.movestopevent = function (callback) {
Return This.each (function () {
var x = 0,
y = 0,
X1 = 0,
Y1 = 0,
Isrun = False,
Si
self = this;
var sif = function () {
si = setinterval (function () {
if (x = = x1 && y ==y1) {
clearinterval (SI);
isrun = false;
callback && callback.call (self);
}
x = x1;
y = y1;
}, 500);
}
$ (this). MouseMove (function (e) {
x1 = E.pagex;
y1 = E.pagey;
!isrun && Sif (), Isrun = true;
}). mouseout (function () {
Clearinterval (SI);
Isrun = false;
});
});
}
}) (JQuery);
$ (function () {
$ ("#div1, #div2"). Movestopevent (function () {
Alert ($ (this). attr ("id"));
}
);
});
</script>
<div id= "Div1" style= "Width:200px;height:100px;background-color: #ccc;" >div1</div>
<br/>
<div id= "Div2" style= "Width:200px;height:100px;background-color: #ccc;" >div2</div>