我正在使用以下 slider 代码
CSS 和 Jquery:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
ASPX:
<p>
<label for="amount">Value:</label>
<input type="text" id="amount" style="border: 0; color: #f6931f; font-weight: bold;" />%
</p>
<div id="slider-vertical" style="height: 15px; width:800px"></div>
<script type="text/javascript">
$(function () {
$("#slider-vertical").slider({
orientation: "horizantal", range: "min", min: 0, max: 100, value: 60,
slide: function (event, ui)
{ $("#amount").val(ui.value); }
});
$("#amount").val($("#slider-vertical").slider("value"));
});
</script>
我正在尝试设置 slider 的值:
function UpdateSlider(PhaseInStatusReportVal) {
$("#slider-vertical").slider("value").val(PhaseInStatusReportVal);
}
我从这样的地方调用上面的代码:
ClientScript.RegisterStartupScript(Me.GetType(), "updatetheslider", "UpdateSlider('" + BCOMSPackageValidationList(0).PhaseInStatusReport.ToString() + "')", True)
但它抛出了上述错误。
有人可以帮我吗?
最佳答案
您是否考虑过采用不同的方法。使用初始值设置隐藏字段 -> 从代码隐藏中填充值,然后执行以下操作:
$(function () {
$("#slider-vertical").slider({
value: $("#hiddenFieldWhatever").val(),
// setup the rest ...
});
});
我希望我正确理解了您的要求。
关于jquery - 在初始化尝试调用方法 'value' 之前无法调用 slider 上的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17287521/