私は本当にjsとJqueryモバイルに苦労しています:(
-jquery-1.7.2.js
-jquery.mobile-1.1.1.js
- Chrome バージョン 20.0.1132.57
私のJavaScript:
<script type="text/javascript" charset="utf-8">
$('#temperature').change(function() {
alert('.change() called.');
});
</script>
</head>
jqmスライダーを使用した私のhtml:
<div data-role="page" data-theme="a">
<div>
<div data-role="header">
<h1>Conditions</h1>
</div>
<div data-role="fieldcontain">
<label for="temperature">Temperature: </label> <input type="range"
name="temperature" id="temperature" value="15" min="-15" max="60"
data-highlight="true" />
</div>
</div>
</div>
質問 1: jquery Mobile を使用しているのに、jquery Mobile を使用していない場合、これが機能しないのはなぜですか?
質問 2: スライダーから値を取得する正しい方法は何ですか? 私は多くのことを試しましたが、成功しませんでした。
質問 3: 値を 1 回変更しても、Fiddle で何度もアラートが発生するのはなぜですか?
質問 4: たとえば 1 つのページに 6 つのスライダーがある場合、値を取得する最良の方法は何ですか?
**EDIT**
私は今そのように変更しましたが、同じ結果:
<script type="text/javascript" charset="utf-8">
function valueChanged(){
var SliderValue = $('#temperature').attr('value');
alert("Slider value = " + SliderValue);
console.log("SliderValue--->" +SliderValue);
}
<div data-role="fieldcontain">
<label for="temperature">Temperature22: </label> <input type="range"
name="temperature" id="temperature" value="15" min="-15" max="60" onchange="valueChanged()"
data-highlight="true" />
</div>
そして、私が得たログで:
SliderValue--->16 条件.html:22 SliderValue--->41 条件.html:22 SliderValue--->41 条件.html:22 SliderValue--->41 条件.html:22 SliderValue--->41 conditions.html:22 SliderValue--->41 conditions.html:22 SliderValue--->41 conditions.html:22 SliderValue--->41 conditions.html:22 SliderValue--->41 conditions.html:22 SliderValue --->41 条件.html:22 スライダー値--->41 条件.html:22
そのため、アラートが無限に開きます。変。
ありがとう!サーミ語