I am trying to get the below html code to work and can’t figure it out. I do not think the domready event is being fired and can’t figure out why.
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<style>
.slider {
background: #CCC;
height: 16px;
width: 200px;
}
.slider .knob {
background: #000;
width: 16px;
height: 16px;
}
</style>
<script type="text/javascript">
window.addEvent('domready', function(){
var slider = $('slider');
new Slider(slider, slider.getElement('.knob'), {
range: [0, 100],
initialStep: 100, steps: 11, wheel: true,
onChange: function(value){
alert(value);
}
});
});
</script>
</head>
<body>
<div id="slider" class="slider">
<div class="knob"></div>
</div>
</body>
</html>
I just want to have a slider on my webpage and can’t use html 5 because of browser restrictions. What is the simplest slider I can use to do this?
First problem that I see is in the
var slider = $('slider');statement.You need to change it to
var slider = $('#slider');orvar slider = $('.slider');depends on if you want to access it via ID or CLASS name.You can also use http://nivo.dev7studios.com/ as a slider which is a good jQuery plugin that I’ve been using.