2012-12-12 35 views
0

我想改變使用jquery滑塊(在移動設備上)的DIV的比例。代碼非常簡單,可以在JS小提琴(http://jsfiddle.net/gsjBC/1/)上工作,但出於某種原因,不能在普通的html頁面上使用。任何人都可以幫助我確定爲什麼不能jquery移動滑塊事件不能觸發

下面是HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Testing</title> 


    <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="fieldcontain"><input type="range" name="slider" id="slider" value="60" min="0" max="100" /></div> 

<script> 
$("#slider").change(function() { 
sliderValue = $(this).val();$("#proportion").width(sliderValue*3); 
$("#proportion").height(300-sliderValue*3);}); 
</script> 

<div id="proportion" style="border:1px solid #ccc; width:150px; height:150px;" /></div> 
</body> 
</html> 

回答

1

地說:

$("#slider").change(function() { 

$(document).ready(function() { 
// here 
}); 
+0

當然的哦!現在我覺得自己像個白癡!謝謝... :) – Dan