手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jQuery实现的支持IE的html滑动条
jQuery实现的支持IE的html滑动条
摘要:复制代码代码如下:.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有所帮助。

【jQuery实现的支持IE的html滑动条】相关文章:

JQuery自动触发事件的方法

jQuery实现给页面换肤的方法

jQuery插件bgStretcher.js实现全屏背景特效

jQuery封装的tab选项卡插件分享

基于jQuery实现的无刷新表格分页实例

javascript实现查找数组中最大值方法汇总

javascript实现简单的进度条

js实现带按钮的上下滚动效果

jQuery实现首页图片淡入淡出效果的方法

javascript实现炫酷的拖动分页

精品推荐
分类导航