Is there a simple JavaScript slider? [closed]

2019-01-21 09:27发布

I need to create a custom volume slider for a WMP object. The current slider is complicated to modify, and use, is there a simple way to generate a slider on an HTML page that can have it's value passed to a javascript function?

13条回答
【Aperson】
2楼-- · 2019-01-21 09:42

HTML 5 with Webforms 2 provides an <input type="range"> which will make the browser generate a native slider for you. Unfortunately all browsers doesn't have support for this, however google has implemented all Webforms 2 controls with js. IIRC the js is intelligent enough to know if the browser has implemented the control, and triggers only if there is no native implementation.

From my point of view it should be considered best practice to use the browsers native controls when possible.

查看更多
forever°为你锁心
3楼-- · 2019-01-21 09:42

The code below should be enough to get you started. Tested in Opera, IE and Chrome.

<script>
var l=0;
function f(i){
im = 'i' + l;
d=document.all[im];
d.height=99;
document.all.f1.t1.value=i;
im = 'i' + i;
d=document.all[im];
d.height=1;
l=i;
}
</script>
<center>
<form id='f1'>
<input type=text value=0 id='t1'>
</form>
<script>
for (i=0;i<=50;i++)
 {
 s = "<img src='j.jpg' height=99 width=9 onMouseOver='f(" + i + ")' id='i" + i + "'>";
 document.write(s);
 }
</script>
查看更多
Anthone
4楼-- · 2019-01-21 09:48

Here is another light JavaScript Slider that seems to fit your needs.

查看更多
趁早两清
5楼-- · 2019-01-21 09:48
地球回转人心会变
6楼-- · 2019-01-21 09:51

I recommend Slider from Filament Group, It has very good user experience

http://www.filamentgroup.com/lab/update_jquery_ui_slider_from_a_select_element_now_with_aria_support/

查看更多
放荡不羁爱自由
7楼-- · 2019-01-21 09:51

Here is a simple slider object for easy to use

pagecolumn_webparts_sliders

查看更多
登录 后发表回答