如何在文本框中显示滑块更改值的结果?

时间:2016-01-13 11:38:37

标签: javascript jquery html

我试图在文本框中显示滑块更改值的结果,但我不知道该怎么做。代码是:

的js

slider = widget.getByName("Slider1");
slider.addValueChangedHandler(
    function (sender, e) {
        alert(sender.getValue());
    }
)
}

Html

</head>
<body>
<div style="clear: both; margin-top: 0px; margin-bottom: 0px; "></div>
<div class="cell" style="height:100px">
  <div class="container" style="height: 100px; margin-bottom: 0px;">
    <div class="widget" style="height: 150px; margin-bottom: 0px;" id="root">
    </div>
  </div>
</div>
<div><input type="text" id="ValueBox" value="0"/></div>
</body>
</html>

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

<强>脚本

slider = widget.getByName("Slider1");
    slider.addValueChangedHandler(
                    function (sender, e) {
                        document.getElementById("ValueBox").value=sender.getValue();
                    }
                )           
            }

        </script>

<强> HTML

 </head>
    <body>
    <div style="clear: both; margin-top: 0px; margin-bottom: 0px; "></div>
    <div class="cell" style="height:100px">
            <div class="container" style="height: 100px; margin-bottom: 0px;">
                <div class="widget" style="height: 150px; margin-bottom: 0px;" id="root">
                </div>
            </div>
        </div>    
    <div><input type="text" id="ValueBox" value="0"/></div>
    </body>
    </html>