如何使用jQuery Mobile的
当我真的与JS和jQuery移动:(如何使用jQuery Mobile的
-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>
我的HTML与JQM滑块:
<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的,但没有它的工作,这是不工作,如果?
问题2:从滑块获取值的正确方法是什么?我尝试了很多,没有成功。
问题3:为什么在小提琴中多次提醒,即使我改变一次值?
问题4:当你在一个页面上使用实例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 conditions.html:22 SliderValue ---> 41 conditions.html:2 2 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 conditions.html:22 SliderValue ---> 41 conditions.html:22 SliderValue ---> 41 conditions.html:22 SliderValue ---> 41 conditions.html:22
因此,它只是无休止地打开警报。奇怪的。
谢谢! 萨米
A1:与$('#temperature').attr('value')
A2只要得到它: - >$('#temperature').attr('value')
A3:我不明白这一点不止一次!?
A4:在函数获取每一个值:
function getTemps(){
var temps = new Array[6];
temps[0]=$('#temperature1').attr('value');
temps[1]=$('#temperature2').attr('value');
and so on...
}
也许帮助:)
谢谢!尝试将鼠标放在结果窗格上并移动它,并且它始终跳跃。当我在Chrome中尝试它时,也会发生在真实应用中。你是否试图为每个滑块或每个滑块使用onchange(“getTemps();”)? – Sami 2012-07-21 15:03:51
如果要在每次更改时将它们保存在数组中,请在每个滑块上添加“onChange =”getTemps()函数。 – heysamhey 2012-07-21 15:09:36
但我仍然没有在Mac/Firefox上获得任何第二次提醒:S – heysamhey 2012-07-21 15:10:02