Jquery click event not working on li in devices(ip

2019-03-29 07:57发布

Jquery click event is not working on li in devices. I tried using click and touchstart events, but the problem when touchstart used is I couldn't scroll down the div. When I try to scroll down by clicking an li, it gets selected. Is there any way to select and scroll li using any jquery events rather than jquery mobile events?

$('#liId').on({ 'touchstart' : function(){ console.log('Event Fired'} });

3条回答
爷、活的狠高调
2楼-- · 2019-03-29 08:27

in your css file

#liId { cursor : pointer; }

jQuery

$('#liId').click(function(){
    alert('Event Fired');
});
查看更多
放荡不羁爱自由
3楼-- · 2019-03-29 08:36

The issue is solved when I added a style class to all li.

.liClass { cursor : pointer; }

查看更多
时光不老,我们不散
4楼-- · 2019-03-29 08:43

replace : with , and unwrap {} before 'touchstart'

$('#liId').on( 'touchstart', function(){ 
 console.log('Event Fired');
});
查看更多
登录 后发表回答