我是jQuery手機的初學者,我試圖做一個簡單的函數,幫助人們通過使用一個滑塊來進行能量計算,用於今天的glastype的單選按鈕組和一個被稱爲moniflex的材料將被用來代替玻璃,並且會導致節能。jQuery Mobile - 麻煩計算和onClick
我遇到的問題是: - onclick事件不適用於safari mac/iPhone。 - 我得到不同的值,但做出了相同的選擇。
代碼:
<script type="text/javascript">
function displayVals() {
var area = $("#slider1").val();
var glas = $("input[name='Ftyp']:checked").val();
var moniflex = $("input[name='Mflex']:checked").val();
var summary = parseFloat(area * (glas - moniflex) * 107.28);
$("#Resultat").html(parseInt(summary) + " kWh");
}
</script>
<div data-role="page" class="gridContainer clearfix">
<div id="LayoutDiv1">
<div data-role="header" id="Header"><img src="img/top.jpg"></div>
<div data-role="content" id="Content">
<div data-role="fieldcontain">
<div id="Resultat" class="Sum">0 kWh</div>
<div id="Yta">
<label for="slider">Value:</label>
<input type="range" name="slider1" id="slider1" value="0" min="0" max="1000" step="1" onChange="displayVals();" data-highlight="true" />
</div>
<div id="Glas">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="horizontal" onClick="displayVals();" >
<legend>Option</legend>
<input type="radio" name="Ftyp" id="Ftyp_0" value="5.5" />
<label for="Ftyp_0">Enkelglas</label>
<input type="radio" name="Ftyp" id="Ftyp_1" value="3" />
<label for="Ftyp_1">Dubbelglas</label>
</fieldset>
</div>
</div>
<div id="Material">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="horizontal" onClick="displayVals();" >
<legend>MONIFLEX</legend>
<input type="radio" name="Mflex" id="Mflex_0" value="3" />
<label for="Mflex_0">10mm</label>
<input type="radio" name="Mflex" id="Mflex_1" value="1.9" />
<label for="Mflex_1">20mm</label>
<input type="radio" name="Mflex" id="Mflex_2" value="1.4" />
<label for="Mflex_2">30mm</label>
</fieldset>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
您在Safari/iOS上收到了什麼值? – Gajotres