javascript - 在 ionRangeSlider 中添加 onChange 事件延迟
问题描述
我正在使用 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
事件添加延迟。
任何帮助,将不胜感激
解决方案
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.
推荐阅读
- angularjs - 从 angularjs 1.5 升级到 angular 5 时如何解决可注入常量
- android - Android Studio 3.3 点击 R.layout.some_layout 问题
- ios - 带有 IBM MobileFirst 服务器的 iOS 应用程序,发出 {"error_description":"Client authentication failed","error":"invalid_client"}
- react-native - 如何在 react-native-datetime-picker 中禁用特定日期?
- java - 为什么上传照片时我的 gui 布局会发生变化?
- google-dfp - 在 Google Admanager (DFP) 中从 lineitemid 获取点击次数和展示次数
- powershell - 将 PowerShell 查询输出到电子邮件
- sql - 来自 2 个表的平均函数
- bit-manipulation - 最后设置位相同的下一个数字
- c++builder - 将事件分配给在运行时动态创建的 VCL 控件 (2)