当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jquery实现鼠标拖动图片效果示例代码

jquery实现鼠标拖动图片效果示例代码

2019年03月20日  | 移动技术网IT编程  | 我要评论

代码如下:


<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "https://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>无标题文档</title><script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript">
$(function(){
$("html").mousemove(function(e){
$("#a").css("left",e.pagex).css("top",e.pagey);
});
});
</script>
<style type="text/css">
.a {
width:200px;
height:100px;
position:absolute;
background-color:rgb(0,0,0);
}
</style>
</head>
<body>

<img src="图片" id="a" name="a" class="a" >

只做了一个简单的实例
</body>

</html>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网