[英]enable jqueryUI slider on click
Im trying to enable the slider when the checkbox is checked! 我试图在选中复选框时启用滑块!
the html: html:
<label for="zerovalueback">Zero Back</label>
<input id="zerovalueback" type="checkbox" name="zerovalueback">
<div id="slider"></div>
<div class="sliderValues">
<span class="leftVal">
</span>
= = =
<span class="rightVal">
</span>
</div>
the script: 剧本:
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('body').on('click', '#zerovalueback', function() {
var status = jQuery(this).prop("checked"); console.log(status);
if (status == 'true') {
jQuery( "#slider" ).slider({
range : "max",
min : 1,
max : 10,
value : 6,
slide: function(event,val){
jQuery('.leftVal').text(val.value);
}
});
};
});
});
Everything is linked correctly, because If I call simply the slider before the on(click) function it works. 一切都正确链接,因为如果我在开启(点击)功能之前简单地调用滑块就可以了。
Does anybody have idea how to solve this? 有谁知道如何解决这个问题?
The if statement was not correct, advice from @DontVoteMeDown was helpfull, it should be if语句不正确,来自@DontVoteMeDown的建议很有帮助,应该是
if (status === true) {
jQuery( "#slider" ).slider({
range : "max",
min : 1,
max : 10,
value : 6,
slide: function(event,val){
jQuery('.leftVal').text(val.value);
}
});
}
If your need is to enable disable jQuery. 如果您需要启用禁用jQuery。 There are methods called enable() and disable().
有一些方法叫做enable()和disable()。 you can find more info here .
你可以在这里找到更多信息。
To disable slider you can use jQuery( "#slider" ).slider('disable');
要禁用滑块,您可以使用
jQuery( "#slider" ).slider('disable');
and to enable slider you can use jQuery( "#slider" ).slider('enable')
并启用滑块,您可以使用
jQuery( "#slider" ).slider('enable')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.