摘:https://www.haorooms.com/post/jquery_on_drag
实时监听 input 输入框的值变化
//输入监听
$('#input').bind('input propertychange', function() {
alert("我是实时监听哦")
});
//回车绑定
$("#input").keydown(function(event){
if(event.which == "13")
//回车执行代码
});
监听事件on写法解释
$(".haorooms").on("click",function(){
alert("haorooms前端博客")
})
$(".haorooms").on({
click:function(){
alert("我是点击事件")
},
mouseover:function(){
alert("mouseover");
},
mouseout:function(){
alert("out")
}
});
最简单的拖拽效果
$(".haorooms_drag").on({
mousedown: function(e){
var el=$(this);
var os = el.offset(); dx = e.pageX-os.left, dy = e.pageY-os.top;
$(document).on('mousemove.drag', function(e){ el.offset({top: e.pageY-dy, left: e.pageX-dx}); });
},
mouseup: function(e){ $(document).off('mousemove.drag'); }