源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jQuery实现的支持IE的html滑动条

  • 时间:2020-03-19 17:04 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jQuery实现的支持IE的html滑动条
[u]复制代码[/u] 代码如下:
<html> <script type="text/javascript" src="jquery.js"></script> <style> .d_b{     height: 20px;     width: 10px;     display: inline-block;     background-color: black;     position: relative;     vertical-align: middle;     top: -15px;     left: -5px; } </style> <div id="d" style="width:200px;cursor: pointer;" max=100 min=0 value=10 > <div style="height:10px; width:100%; background-color:green" ></div> <b class="d_b"></b> </div> <b id="text"></b> <script> var $dom = $(document); $dom.on('mousedown','#d',function (argument) {     $(this).data('mouse','down');     console.log('down'); }) $dom.on('mouseup',function(){     $('#d').data('mouse','up');     console.log('up'); }); $dom.on('mousemove','#d',function(event){     if($(this).data('mouse') == 'down'){         var m_x = event.clientX;         var d_b = $(this).find('.d_b');         m_x = m_x < 8 ? 8 : m_x;         m_x = m_x > 208 ? 208: m_x;         d_b.css('left',m_x-13);         var max = $(this).attr('max');         $(this).attr('value', Math.floor((m_x-8)/200 * max))         console.log($(this).attr('value'));         $('#text').text($(this).attr('value'))     } }); </script> </html>
效果图: [img]http://files.jb51.net/file_images/article/201503/2015031611021614.png[/img] 以上就是本文的全部内容了,希望能够对大家学习使用jQuery有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部