jQuery实现的支持IE的html滑动条
作者:bea
代码如下: <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: mid
代码如下:
<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>
效果图:
以上就是本文的全部内容了,希望能够对大家学习使用jQuery有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- jquery通过closest选择器修改上级元素的方法
- jQuery判断元素上是否绑定了指定事件的方法
- jQuery验证元素是否为空的两种常用方法
- jQuery在ul中显示某个li索引号的方法
- jQuery支持动态参数将函数绑定到事件上的方法
- jQuery实现预加载图片的方法
- jQuery检测鼠标左键和右键点击的方法
- jQuery对指定元素中指定字符串进行替换的方法
- jQuery经过一段时间自动隐藏指定元素的方法
- input输入框鼠标焦点提示信息
- 原生JS实现LOADING效果
- 使用jQuery实现图片遮罩半透明坠落遮挡
- jQuery+css3动画属性制作猎豹浏览器宽屏banner焦点图
- JavaScript中使用Callback控制流程介绍
- jquery图片切换插件
- JavaScript中的方法重载实例
- jquery中attr和prop的区别分析
- JavaScript中扩展Array contains方法实例
- JavaScript中消除闭包的一般方法介绍