下面给大家带来的是jQuery如何实现磁力图片跟随效果例子源码分享,结合完整实例形式分析了jQuery事件响应及animate方法实现带缓冲效果的图片跟随效果,有兴趣的来看看吧。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>磁力图片</title>
<style type="text/css">
#imgSel{position:absolute;}
</style>
<script src="../js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$(document).mousemove(function (e) {
$("#imgSel").animate({"left":e.pageX,"top":e.pageY},0.1);
});
});
</script>
</head>
<body>
<img id="imgSel" src="../images/select.JPG" />
</body>
</html>