问题
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>
回答1:
your jsfiddle have onLoad like this:
//<![CDATA[
$(window).load(function(){
$("#slider-step").on("slidestop", function(e){
alert("STOP!");
});
});//]]>
and you only coppy the script on your page without $(window).load or $(document).ready jsfiddle
来源:https://stackoverflow.com/questions/16799382/jquerymobile-slider-change-event