目标
在单击时关闭锚点标签的父div。在下面的代码中,当用户单击锚点标签close_performance_tt时,我想隐藏
performance_tt
。
问题
在iOS设备上花费了几个小时后无法使其正常工作。在其他所有设备上都可以正常工作,甚至在BlackBerry 10设备上也可以。
<div id="performance_tt" style="display: none;width: 300px;height: 200;overflow: auto;padding: 5px;background-color: yellow;">
<div>Website performance has become an important consideration for most sites.
The speed of a website affects usage and user satisfaction, as well as search engine rankings, a factor that directly correlates to revenue and retention.
As a result, creating a system that is optimized for fast responses and low latency is key.</div>
<a id="close_performance_tt" href="#">Close</a>
<script>
var userAgent = navigator.userAgent.toLowerCase();
var isiOS = (navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false);
if (isiOS) {
$("#close_performance_tt").bind('touchstart', function() {
alert('Touch-start event triggered');
});
} else {
$("#close_performance_tt").bind('click', function() {
alert('Click event triggered');
});
}
</script>
</div>
$("#close_performance_tt").bind('click touchstart', ..)
而不是if..else
? - Arun P JohnyisiOS
具有正确的值。 - Arun P Johny