如何使用 CSS 防止点击事件?

如何使用 CSS 防止点击事件?

我已经创建了表单页面,那么我需要防止点击事件只使用 CSS?
我试过这个 CSS 属性,但没有工作。

<div>Content</div>
div {
display: none;
}
128627 次浏览

You can try the css class:

.noClick {
pointer-events: none;
}

I did the following to still allow hover events:

element.addEventListener("focusin", function(event) {
this.blur()
})

It removes focus from the element once focused. It makes sure that the element won't ever get focus.

It's very suitable for the input tag.

However I don't recommend it if you want a good tab-key-experience.