Is there a way to put a JavaScript variable into slider's "max" attribute value? For example,
<script type="text/javascript">
myVar="20";
</script>
<input id="slider1" name="sliderr" type="range" max="myVar"></input>
Is there a way to put a JavaScript variable into slider's "max" attribute value? For example,
<script type="text/javascript">
myVar="20";
</script>
<input id="slider1" name="sliderr" type="range" max="myVar"></input>
Share
Improve this question
asked May 23, 2014 at 11:27
StartedFromTheBottomStartedFromTheBottom
3258 silver badges21 bronze badges
2 Answers
Reset to default 6Try this
var myVar = 20;
document.getElementById("slider1").max = myVar;
// or
//document.getElementById("slider1").setAttribute("max", myVar);
Demo
Try this:
html
<input id="slider1" name="sliderr" type="range" max="myVar"></input>
js
document.getElementById("slider1").setAttribute("max",20);
fiddle
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744996378a4605216.html
评论列表(0条)