【发布时间】:2018-02-04 02:00:32
【问题描述】:
span 元素上的 Click 事件会在桌面设备上触发,但不会在移动设备上触发。跨度是用户单击“获取天气”按钮后填充的当前温度旁边的温度单位。
这是与跨度点击事件相关的代码部分:
$(document).on('click', "span" , function(){
var str=document.getElementById("tempUnits").innerHTML;
if (str==="Celsius"){
document.getElementById("tempUnits").innerHTML="Fahrenheit";
$("#temp").html(tempC + '<span id="tempUnitsSpan"><strong> C </strong></span>' + " and " + weatherDescription);
}
else if (str==="Fahrenheit"){
document.getElementById("tempUnits").innerHTML="Celsius";
tempF=Math.max( Math.round((tempC*1.8+32) * 10) / 10, 2.8 ).toFixed(2);
console.log(tempF);
$("#temp").html(tempF + '<span id="tempUnitsSpan"><strong> F </strong></span>' + " and " + weatherDescription);
}
【问题讨论】:
-
在手机上点击两次能用吗?
-
@messerbill(不,用原始代码点击两次后不起作用)
标签: javascript jquery mobile responsive