有没有办法将JavaScript变量放入滑块的" max" 属性值? 例如,
<script type="text/javascript">
myVar="20";
</script>
<input id="slider1" name="sliderr" type="range" max="myVar"></input>
答案 0 :(得分:3)
试试这个
var myVar = 20;
document.getElementById("slider1").max = myVar;
// or
//document.getElementById("slider1").setAttribute("max", myVar);
答案 1 :(得分:2)
试试这个:
<强> HTML 强>
<input id="slider1" name="sliderr" type="range" max="myVar"></input>
<强> JS 强>
document.getElementById("slider1").setAttribute("max",20);