这里有新鲜出炉的 jQuery 示例,程序狗速度看过来!
jQuery 是一个兼容多浏览器的 javascript 框架,核心理念是 write less,do more(写得更少, 做得更多)。jQuery 在 2006 年 1 月由美国人 John Resig 在纽约的 barcamp 发布,吸引了来自世界各地的众多 JavaScript 高手加入,由 Dave Methvin 率领团队进行开发。
本文给大家分享的是一段使用 jQuery 实现支持 IE 的 html 滑动条代码,效果非常不错,这里推荐给大家,希望大家能够喜欢。
- <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>
效果图:
来源: http://www.phperz.com/article/17/0417/272269.html