Jquery mobile click event doesn't work

给你一囗甜甜゛ 提交于 2019-11-27 08:11:58

问题


When i try to trigger an event click with a mobile browser the "click" doesn't work. With Firefox for Desktop works fine.

This is my html:

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

And this is my jquery:

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

Can you explain me? Thanks.


回答1:


Use touch events

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

http://jsfiddle.net/9x9fm/




回答2:


Try to use event delegation here:

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



回答3:


Try to use like this:

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


来源:https://stackoverflow.com/questions/21776570/jquery-mobile-click-event-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!