2013-05-28 49 views
1

我在收聽jQueryMobile滑塊的更改事件時遇到困難。

在這個頁面中,該事件正確地觸發事件「slidestop」:
http://jsfiddle.net/2HEcY/
相同代碼在我的網頁沒有任何觸發:
http://www.marianotomatis.it/test.php

你能看到的任何問題,在此代碼?jQueryMobile滑塊更改事件

<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

您的jsfiddle已經onLoad的調用是這樣的:

//<![CDATA[ 
$(window).load(function(){ 
$("#slider-step").on("slidestop", function(e){ 
    alert("STOP!"); 
}); 
});//]]>  

,你只coppy您的網頁上的腳本,而不$(窗口).load或$(文件)。就緒 jsfiddle

+0

它完全解決了我的問題,非常感謝。 –