简体   繁体   English

更改后带有滑块值的弹出窗口

[英]Popup with value of slider when it's changed

I have the next jsfiddle: 我有下一个jsfiddle:

https://jsfiddle.net/alonshmiel/vxz7fnvk/1/ https://jsfiddle.net/alonshmiel/vxz7fnvk/1/

There is a slider with an ellipse that contains arrows. 有一个带有椭圆的滑块,其中包含箭头。

I want to write a function that shows a popup with the value of the ellipse when the user changes the value. 我想编写一个函数,当用户更改值时显示带有椭圆值的弹出窗口。

BUT: There are two options to scroll it: 但是:有两个选项可以滚动它:

1) When you click on a certain value, a popup with the value will be shown on the screen. 1)当您单击某个值时,带有该值的弹出窗口将显示在屏幕上。

2) When you click on the ellipse and move it to the left or right, and then stop clicking on the ellipse (in other words, stop scrolling it), a popup with the value will be shown on the screen with the value. 2)单击椭圆并将其向左或向右移动,然后停止单击椭圆(换句话说,停止滚动)时,将在屏幕上显示带有该值的弹出窗口。

$("#slider").slider({
    value:30,
    min: 0,
    max: 100,
    step: 10,
    slide: function( event, ui ) {
        $( "#slider a" ).html("<span class='Triangles'>&#9664;&#9654;</span>");
        $( "#slider-value" ).html(ui.value);            
    }
});

Any help appreciated! 任何帮助表示赞赏!

You want to bind to the stop event. 您想绑定到stop事件。 It will fire when the user stops dragging or when the click at a different point on the slider. 当用户停止拖动或在滑块上的另一点单击时,它将触发。

This is your updated code: 这是您更新的代码:

$("#slider").slider({
    value: 30,
    min: 0,
    max: 100,
    step: 10,
    slide: function (event, ui) {
        $("#slider a").html("<span class='Triangles'>&#9664;&#9654;</span>");
        $("#slider-value").html(ui.value);
    },
    stop: function (event, ui) {
        alert(ui.value);
    }
});

Working Fiddle: https://jsfiddle.net/vxz7fnvk/3/ 工作小提琴: https : //jsfiddle.net/vxz7fnvk/3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更改值时防止滑块跳动 - Prevent slider from jumping when value is changed 通过滑块更改输入值时设置状态-ReactJS - Set state when input value changed by a slider - ReactJS 快速更改值时使 HTML 滑块不跳过值 - Make HTML slider not skip values when value is changed quickly 下拉选项卡更改时范围 slider 的值更改 - Value change of range slider when drop-down tab changed 当sweetalert弹出消息显示时如何使复选框值不改变 - How to make checkbox value not changed when sweetalert popup message show 使用某些弹出窗口更改但手动更改时,on(&#39;change:&#39;)事件不接受文本框值 - on('change:') event not accepting textbox value when changed using some popup but when changed manually AngularJS rzslider不发送更改的滑块值 - AngularJS rzslider not sending changed slider value 如何保存滑块jQuery UI的更改值 - How to save changed value of slider jQuery UI AngularJS:如何听 <input ng-change> 用滑块更改值时? - AngularJS: How to listen to <input ng-change> when value is changed with a Slider? 如何在用户释放范围滑块时触发“更改”事件,即使该值未更改 - How to fire a “change” event when the user releases the range slider, even if the value hasn't changed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM