如何检测 jquery 移动输入滑块何时在 jquery 上移动
how to detect when a jquery mobile Input slider is moved on jquery?
我一直在尝试检测jQuery移动输入滑块何时移动,以便我可以获取其值,问题是滑块的句柄在我应用脚本或正在发生的任何事情后呈现,所以我无法检测到其中的更改。
有人可以解释为什么这是,如果可能的话,一个解决方案?
实时代码:http://liveweave.com/hrrHzP
我的JS和HTML分别:
$(document).ready(function() {
$('#slider-s').mousedown(function() {
$(document).mousemove(function() {
$("#title").css({
"background-color": "#" + $("#slider-s").attr("value")
});
});
});
});
<!DOCTYPE html>
<html>
<head>
<title>MobilePage</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<link rel="stylesheet" href="https://view.jquerymobile.com/1.4.5/theme-classic/theme-classic.css" />
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
</head>
<body>
<div data-role="page" data-theme="c">
<div role="main" class="ui-content">
<h1 id="title">Title</h1>
<label for="slider-s">Input slider:</label>
<input type="range" name="slider-s" id="slider-s" min="111111" max="999999" data-highlight="true">
</div>
</div>
</body>
</html>
您可以使用滑块和事件委托的更改事件:
$(document).on("pagecreate","#page1", function(){
$(document).on("change", "#slider-s", function(){
var col = $(this).val();
$("#title").css({
"background-color": "#" + col
});
});
});
演示
这是因为事件委派。尝试这样的东西
$( "html" ).on( "click", "#slider-s", function() {
console.log('success');
});
进一步解释。http://api.jquery.com/on/https://learn.jquery.com/events/event-delegation/
相关文章:
- 正在SharePoint 2013母版页中添加JQuery移动文件
- 停止jQuery UI滑块移动超过给定值
- 如何将chrome扩展功能移植到移动设备(特别是jquery和trello)
- JQuery移动动态分区页面
- jquery移动对齐按钮取决于内容大小
- 如何在jquery中找到鼠标滚轮/触摸移动事件的走向
- 简单的垂直上一个和下一个按钮代码点击上下移动jQuery
- 将闪烁的图像从左向右移动 jquery
- 鼠标移动 jquery 上的多个转换
- 使用POST从PhoneGap,移动jQuery应用程序跨域脚本检测成功的html表单提交
- 移动.jQuery中的changepage不工作(白屏)
- 创建移动jQuery切换菜单
- 元素拒绝移动- jQuery .css
- 力“Tab"在元素内移动- Jquery/Javascript
- 实时图像大小调整和移动(JQuery)
- .click()和.trigger("click")都不能用于移动jquery图标按钮.我怎样才能解
- 如何重置移动JQuery表单
- 用鼠标移动jQuery自定义工具提示
- 移动 jquery onclick 不播放音频文件
- 移动jquery页面是不断加载,如果我把自定义参数在URL