1. 程式人生 > >圖片隨鼠標動(jQuery)

圖片隨鼠標動(jQuery)

relative query UNC bsp mar etx AD ctype left

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/jquery-1.12.3 (1).js"></script>
<style type="text/css">
.wap{
height: 500px;
width: 500px;
background-color:aquamarine;
position: relative;
}
img{
position: absolute;
}
</style>

<script type="text/javascript">
$(function(){
$(".wap").mousemove(function(e){
$(".img").css({
"top":e.offsetY,
"left":e.offsetX
})
});
});
</script>

</head>
<body>
<div class="wap">

</div>
<img class="img" height="30" width="30" src="img/untitled.png"/>
</body>
</html>

圖片隨鼠標動(jQuery)