0

(モバイルデバイスで)jqueryスライダーを使用してDIVの比率を変更したい。コードは非常に単純で、JS Fiddle(http://jsfiddle.net/gsjBC/1/)で機能しますが、何らかの理由で通常のhtmlページでは機能しません。誰かが私がなぜそうしないのかを特定するのを手伝ってもらえますか?

これが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>
4

1 に答える 1

1

置く:

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

$(document).ready(function() {
// here
});
于 2012-12-12T10:27:02.520 に答える