JQuery UI offers some functional sliders that can be used in multiple instances per page. You do not need to write or modify as much code to use them as above. If you are not trying to avoid jquery, this might be the best option for you.
Here is a link to a demonstration of several sliders .
The approach used for several sliders, of course, depends on jquery, but taking into account the markup, for example:
<div id="eq"> <span>88</span> <span>77</span> <span>55</span> <span>33</span> <span>40</span> <span>45</span> <span>70</span> </div>
A simple .each statement processes them all.
$( "#eq > span" ).each(function() { // read initial values from markup and remove that var value = parseInt( $( this ).text(), 10 ); $( this ).empty().slider({ value: value, range: "min", animate: true, orientation: "vertical" }); });
Edit:. According to the comments below, if you want to add tooltips / tooltips, you need to minimize your own. Here is a quick example from some code that I wrote last year. It has some specific behaviors that fit the needs of my users, but this should give you an idea. The identifier "hintrow" refers to the row of the table on the grid containing my slider. Thanks to experimentation, you can find a better place compared to your sliders to add this. It will be located so that you want the dom node to add it.
function drawExtCues(){ z = 200; $('#hintrow').append('<div id="hintContainer" style="position:relative"></div>'); for(h in rowobjects){ z++; $('#hintContainer').append('<div title="' + rowobject[h].property1 + '" class="' + rowobject[h].property2+ ' ui-slider-range hint" style="z-index:' + z +';">' + rowobject[h].property1+ '</div>'); } $('.hint').mouseover(function(){ hintMouseOver(); }); } function hintMouseOver(){ $('.hint').addClass('hintInspect',500); $('.hint').unbind('mouseover'); $('.hint').click(function(){ $J('.hint').removeClass('hintInspect',500); $J('.hint').mouseover(function(){hintMouseOver();}) }); }
Pay attention to z ++. This was used to ensure that my tool tips stacked up. Since we made them click to reject in our case, this worked well. You do not need to do this, but if you do not use the click to reject, you may need to bind a timeout to clear the hint for you.
The hintMouseOver function does some house cleaning, such as disconnecting itself to prevent repeated calls. This is a rebound after the click event to reject the tooltip is fired. This is just the behavior of my client. You could do a lot here. The hintInspect class is basically style rules for how the tooltip appears. You can do as you like. It seems I just used a simple black outline with a gray background.