<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>鼠标拖拽</title>
<script src="jquery-1.8.3.min.js"></script>
<style>
*{
margin:0;padding:0;
}
.box{
width:200px;
height:200px;
background:#c4c4c4;
position:absolute;
}
</style>
</head>
<body>
<div class ='box'></div>
<button>用ON方法绑定</button>
<script>
//基本绑定
//$('button').click(function(){
//alert('ok');
//})
//on方法绑定
//$('button').on('click',function(){
//alert('我是on')
//})
//一次绑定多个事件
// $('button').on({mouseover:function(){console.log('我进来啦')},mouseout:function(){console.log('我出来啦')}})
//接触绑定
//$('button').off();
// 鼠标拖拽效果
// 当用户在div中按下 移动 让div跟着鼠标移动
// 1.给div绑定一个鼠标按下事件
// 2.给div绑定一个鼠标移动事件
// 3.获
JQuery事件绑定和拖拽效果
最新推荐文章于 2022-06-02 10:49:18 发布