javascript - 如何为 touchstart / touchend 事件禁用按钮?
问题描述
我很惊讶地发现该按钮的 disabled 属性在网站的移动版本上被忽略了。如何禁用 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)
});
解决方案
我遇到了同样的问题并找到了这个主题。
只要我尝试过,disabled
属性 disabled onClick
,但没有禁用onTouchStart
和onTouchEnd
.
实际上,onTouchStart
并且onTouchEnd
不是<button>
. 我想这就是原因。
推荐阅读
- sql - SQL 获取本年度直到前一周星期五的数据
- docker - 启动失败,ddev-router 无法准备好,复制上游
- python - 来自同一模型的 Django 两个 ForeignKey
- python - 在 QStackedWidget 对象内定位内部小部件
- sqlite - 为矩阵创建sql表并将csv文件插入表中
- github - 如何在 Github 上更新拉取请求
- javascript - Sequelize:使用函数添加默认范围
- security - 如何允许具有内容安全策略 (CSP) 的 iframe
- javascript - 如何使用打字稿通过其名称作为变量引用枚举
- r - 使用 purr 和 RoogleVision 批量调用 Google Vision 的整洁方法?