本文介绍了jQueryMobile滑块更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在收听jQueryMobile滑块的change事件时遇到困难.
在此页面中,事件正确触发了事件"slidestop":
http://jsfiddle.net/2HEcY/
我页面中的相同代码不会触发任何操作:
http://www.marianotomatis.it/test.php
您可以在这段代码中看到任何问题吗?
I have difficulties in listening to the change event of a jQueryMobile slider.
In this page, the event triggers correctly the event "slidestop":
http://jsfiddle.net/2HEcY/
The same code in my page doesn't triggers anything:
http://www.marianotomatis.it/test.php
Can you see any problem in this code?
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>My Title</h1>
</div><!-- /header -->
<div data-role="content">
<label for="slider-step">Input slider:</label>
<input type="range" name="slider-step" id="slider-step" value="150" min="0" max="500" />
</div><!-- /content -->
</div><!-- /page -->
<script>$("#slider-step").on("slidestop", function(e){ alert("STOP!"); });</script>
</body>
</html>
推荐答案
您的jsfiddle具有如下的onLoad:
your jsfiddle have onLoad like this:
//<![CDATA[
$(window).load(function(){
$("#slider-step").on("slidestop", function(e){
alert("STOP!");
});
});//]]>
,您只复制没有$(window).load或$(document).ready的页面上的脚本 jsfiddle
and you only coppy the script on your page without $(window).load or $(document).readyjsfiddle
这篇关于jQueryMobile滑块更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!