简体   繁体   English

Jquery移动点击事件不起作用

[英]Jquery mobile click event doesn't work

When i try to trigger an event click with a mobile browser the "click" doesn't work. 当我尝试使用移动浏览器触发事件​​时,“单击”不起作用。 With Firefox for Desktop works fine. 使用Firefox for Desktop工作正常。

This is my html: 这是我的HTML:

<li class='brand'></li>

And this is my jquery: 这是我的jquery:

$('.brand').click(function() { alert('ok') });

Can you explain me? 你能解释一下吗? Thanks. 谢谢。

Use touch events 使用触摸事件

$(document).on('click touchstart', '.brand', function() {
    alert('ok');
});

http://jsfiddle.net/9x9fm/ http://jsfiddle.net/9x9fm/

Try to use event delegation here: 尝试在此处使用事件委派:

$(document).on('click', '.brand', function() {
    alert('ok');
});
Try to use like this:

$('.brand').on('click' function() {
    alert('ok');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM