我惊讶地看到,该按钮的禁用属性在站点的移动版本中被忽略了。如何禁用touchstart / touchend事件按钮?<button ontouchend="alert();" disabled="disabled" style="touch-event: none">Test for touch</button>在触摸后显示alert(),忽略禁用的属性。我试着用touch-event: none的风格-什么都没发生
UPD。下面是一些代码--它是可行的,但对于简单的使用却不是很好。
$("button").on("touchend", function()
{
if($(this).is(":disabled") == false)
alert(1)
}); 发布于 2019-08-09 09:40:39
我也面临着同样的问题,并找到了这个话题。
只要我尝试过,disabled属性就禁用了onClick,但是没有禁用onTouchStart和onTouchEnd。
实际上,onTouchStart和onTouchEnd并不是<button>的官方财产。我想这就是原因。
发布于 2022-03-01 15:57:15
可以使用css将touch-action: none属性添加到按钮容器中。
https://stackoverflow.com/questions/57420098
复制相似问题