Set the max value for slider in JavaScript

Description

The following code shows how to set the max value for slider.

Example


<!--from   ww w.j a  v a2s  .  c o  m-->


<html lang="en">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
var sliderOpts = {
max: 255,
steps: 255,
slide: function(e, ui) {
var val = $(this).slider("value");
var id = $(this).attr("id");
$("#output").text(val);
}
};
$("#rSlider").slider(sliderOpts);
});
</script>
</head>
<body>
<div id="container">
<div id="rSlider"></div><br>
<div id="output">
</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Set the max value for slider in JavaScript