【发布时间】:2016-02-24 23:26:10
【问题描述】:
我一直在尝试检测 jQuery Mobile 输入滑块何时移动,以便我可以获取它的值,问题是滑块的句柄在我应用我的脚本或发生任何事情后呈现,所以我无法检测到变化它。
有人可以解释为什么会这样,如果可能的话,可以提供解决方案吗?
直播代码: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>
【问题讨论】:
-
@freedomn-m 我想坚持手机版
-
您可能想阅读以下内容:mcve。您提供的大部分代码都与滑块无关。
-
好的 - 你试过收听
change事件吗?还是slidestop? -
我尝试了更改,但它实际上并没有(奇怪地)监听输入的任何更改
-
你能用 jquerymobile 创建一个 jsfiddle(或等效的)吗?我试过了,但是一旦 jquerymobile 加载,滑块就不再是滑块,而没有 jquerymobile(浏览器滑块)是一个不错的滑块
标签: javascript jquery jquery-mobile