0

我正在使用 ionRangeSlider 的价格范围:

HTML

<input class="range-slider" id="price_range">

JS

        $("#price_range").ionRangeSlider({
            min: 0,
            max: 10000,
            type: "double",
            grid: false,
            step: 500,
            force_edges: true,
            decorate_both: false,
            prettify_enabled: true,
            onChange: function (data) {
                $('#loading').show();
                window.location.replace("@Url");
            },
        });

我想onChange在重定向到 url 之前添加 2 秒的延迟。

我查看了文档,但找不到如何为 onChange事件添加延迟。

任何帮助,将不胜感激

4

1 回答 1

0

Maybe you can try something like this -

<body>
    <select id="select">
        <option>1</option>
        <option>2</option>
        <option>3</option>
    </select>
    <script>
        var wto;
        $('#select').change(function() {
          wto = setTimeout(function() {
            // write your code here
            console.log('something changed');
          }, 2000);
        });
    </script>
</body>

This change gets triggered whenever a new value is selected from the drop-down, but the alert will come after 2 seconds only.

Try this and let me know if you're looking for something else.

于 2018-06-03T19:54:59.807 回答