0
我留神聽與jQuery的事件如下:檢測touchstart只有元素有一個特定的類
$(document).on('click touchstart', '.open-qv', function(e){
e.preventDefault();
但是我只是想監聽/檢測touchstart
如果元素感動了特定類如。 .hotspot
如果它沒有這個類,我只想聽點擊,有沒有辦法做到這一點?
我留神聽與jQuery的事件如下:檢測touchstart只有元素有一個特定的類
$(document).on('click touchstart', '.open-qv', function(e){
e.preventDefault();
但是我只是想監聽/檢測touchstart
如果元素感動了特定類如。 .hotspot
如果它沒有這個類,我只想聽點擊,有沒有辦法做到這一點?
您應該使用event.type
檢查這兩種情況下不touchstart或元素.hasClass()
熱點:
$(document).on('click touchstart', '.open-qv', function(e){
if(event.type!="touchstart" || $(this).hasClass('hotspot')){
//do stuff
}