jQuery实现的支持IE的html滑动条
jQuery实现的支持IE的html滑动条
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:.d_b{height:20px;width:10px;display:inline-block;background-c...

复制代码 代码如下:

<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" max=100 min=0 value=10 >

<div ></div>

<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实现的支持IE的html滑动条1

以上就是本文的全部内容了,希望能够对大家学习使用jQuery有所帮助。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类