【问题标题】:Event max in slider jquery ui滑块jquery ui中的事件最大值
【发布时间】:2015-03-13 21:14:20
【问题描述】:

jquery ui中slider的事件有create、start、slide、change和stop

当用户达到最大值时我该怎么办?

【问题讨论】:

    标签: jquery-ui events


    【解决方案1】:

    您可以处理slide 事件并检查当前滑块值是否等于其max 选项:

    $("#yourSlider").slider({
        slide: function(event, ui) {
            if (ui.value == $(this).data("ui-slider").options.max) {
                // Slider has reached maximum value.
            }
        }
    });
    

    【讨论】:

    • 您先生,它有效吗?我尝试了这个并在 console.log($(this).data("slider")) 上得到了 undefined
    • @Thompson,你说得对,自从jQuery UI 1.9 changed the key used to access the widget instance through data() 之后,这个解决方案就不再起作用了。我当时做了一系列更新,但我显然错过了这个答案。修改后的版本应该可以在 jQuery UI 1.9+ 上正常工作。感谢您引起我的注意:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多