帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» mousedown后滑动选择checkbox
mousedown后滑动选择checkbox
浏览:570次
-
评论:0次
-
发布时间:2017-11-30
Html
Css
Js
查看结果数据
结果数据
html { font-family:sans-serif; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; } body { margin:0; } .btn { display:inline-block; padding:6px 12px; margin-bottom:0; font-size:14px; font-weight:normal; line-height:1.42857143; text-align:center; white-space:nowrap; vertical-align:middle; -ms-touch-action:manipulation; touch-action:manipulation; cursor:pointer; -webkit-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none; background-image:none; border:1px solid transparent; border-radius:4px; } .btn:focus,.btn:active:focus,.btn.active:focus,.btn.focus,.btn:active.focus,.btn.active.focus { outline:5px auto -webkit-focus-ring-color; outline-offset:-2px; } .btn:hover,.btn:focus,.btn.focus { color:#333; text-decoration:none; } .btn:active,.btn.active { background-image:none; outline:0; -webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125); box-shadow:inset 0 3px 5px rgba(0,0,0,.125); } .row { margin-right:-15px; margin-left:-15px; } .col-xs-1,.col-sm-1,.col-md-1,.col-lg-1,.col-xs-2,.col-sm-2,.col-md-2,.col-lg-2,.col-xs-3,.col-sm-3,.col-md-3,.col-lg-3,.col-xs-4,.col-sm-4,.col-md-4,.col-lg-4,.col-xs-5,.col-sm-5,.col-md-5,.col-lg-5,.col-xs-6,.col-sm-6,.col-md-6,.col-lg-6,.col-xs-7,.col-sm-7,.col-md-7,.col-lg-7,.col-xs-8,.col-sm-8,.col-md-8,.col-lg-8,.col-xs-9,.col-sm-9,.col-md-9,.col-lg-9,.col-xs-10,.col-sm-10,.col-md-10,.col-lg-10,.col-xs-11,.col-sm-11,.col-md-11,.col-lg-11,.col-xs-12,.col-sm-12,.col-md-12,.col-lg-12 { position:relative; min-height:1px; padding-right:15px; padding-left:15px; } .col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12 { float:left; } .col-xs-12 { width:100%; } .col-xs-11 { width:91.66666667%; } .col-xs-10 { width:83.33333333%; } .col-xs-9 { width:75%; } .col-xs-8 { width:66.66666667%; } .col-xs-7 { width:58.33333333%; } .col-xs-6 { width:50%; } .col-xs-5 { width:41.66666667%; } .col-xs-4 { width:33.33333333%; } .col-xs-3 { width:25%; } .col-xs-2 { width:16.66666667%; } .col-xs-1 { width:8.33333333%; } #container { -webkit-touch-callout:none; -webkit-user-select:none; -khtml-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none; }
$.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; } /* 生成 dom */ var domStr = ''; for (var i = 0; i < 50; i++) { domStr += '' + '
' + '
' + '
value' + i + '
' + '
'; } $('#container').append(domStr); /* 事件监听 */ $(document) .on('mousedown', function(event) { if (event.target.tagName === 'LABEL') { $(event.target).find('input').addClass('moving'); } $(document).on('mousemove', function(e) { if ($(e.target).closest('#container').length === 1) { var $checkbox = $(e.target).find('input'); if ($(e.target).attr('id') !== 'container' && e.target.tagName !== 'DIV') { if (!$checkbox.hasClass('moving')) { if ($checkbox.prop('checked')) { $checkbox.prop('checked', false); } else { $checkbox.prop('checked', true); } } $checkbox.addClass('moving'); } } }); }) .on('mouseup', function() { $('#container input').removeClass('moving'); $(document).off('mousemove'); }) .on('click', '#checkData', function() { var data = JSON.stringify($("form").serializeObject(), null, 4); $('#data').empty().append('
' + data + '
'); })
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
2.1.4
<!doctype html><html><head><meta charset="utf-8"><title>mousedown后滑动选择checkbox-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:鼠标点击后,滑动到对应的checkbox,进行勾选
3D照片旋转
文字的渐变效果
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
570
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值