jquery.click()无法在iOS中运行 [英] jquery.click() not working in iOS
本文介绍了jquery.click()无法在iOS中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HTML:
<div id="footer">
<a class="button1 selected" id="button1" href="#"><div class="icon"></div><div class="text">Option 1</div></a>
<a class="button2" id="button2" href="#"><div class="icon"></div><div class="text">Option 2</div></a>
<a class="button3" id="button3" href="#"><div class="icon"></div><div class="text">Option 3</div></a>
<a class="button4" id="button4" href="#"><div class="icon"></div><div class="text">Option 4</div></a>
</div>
JS:
$('#button1').click(function() {
alert('button1');
});
$('#button2').click(function() {
alert('button2');
});
现在,这个脚本在我的PC浏览器上完美运行,但它在iOS上不起作用。我也试过这个解决方案: $(document).click()在iPhone上无法正常工作。 jquery 但它没有用。
Now, this script works perfectly on my PC Browser but it doesn't work on iOS. I've tried this solution too: $(document).click() not working correctly on iPhone. jquery but it doesen't work.
我在jQuery 1.8.3上使用,没有jQuery Mobile(我不喜欢)。
I am using on jQuery 1.8.3, no jQuery Mobile (I prefer not to).
有人可以帮我这个吗?
推荐答案
尝试添加指针光标到按钮并使用.on来绑定点击事件
Try to add a pointer cursor to the button and use .on to bind click event
$('#button1').css('cursor','pointer');
$(document).on('click', '#button1', function(event) {
event.preventDefault()
alert('button1');
});
这篇关于jquery.click()无法在iOS中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文