jQueryMobile slider change event

依然范特西╮ 提交于 2019-12-20 05:29:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!