How to set non-clickable in html

青灯夜游
Release: 2023-01-06 11:13:37
Original
5964 people have browsed it

In HTML, you can use the pointer-events attribute to achieve the non-clickable effect of the element by setting the mouse event of the element to invalid. You only need to set the "pointer-events:none;" style to the element.

How to set non-clickable in html

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

htmlSet non-clickable

Make the element non-clickable by setting the pointer-events attribute of the element to none. This method makes the element unclickable by setting the mouse event of the element to invalid.

css code:

.disable { pointer-events: none; }
Copy after login

Example:

const disabled = true; 
Copy after login

Rendering:

##Note:

  • When the value of pointer-events is none, if the element is absolutely positioned, the element below it can be selected.

  • pointer-events: none; It is only used to disable mouse events. Events bound by other methods will still be triggered, such as keyboard events, etc.

  • If the pointer-events of a child element of an element is set to another value (for example: auto), then when the child element is clicked, the parent element will still be triggered by event bubbling. event.

(Learning video sharing:

css video tutorial, "html video tutorial")

The above is the detailed content of How to set non-clickable in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!