如何禁用 HTML 标签?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2533406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:35:07  来源:igfitidea点击:

How to disable a HTML tag?

csshtml

提问by Simon

I want to disable a tag if it's already set -- e.g., disable a menu using disabled = "true"or something.

如果标签已经设置,我想禁用它——例如,禁用菜单使用disabled = "true"或其他东西。

I can remove a tag completely using PHP; but I have already styled it and only want to disable it. Is it possible?

我可以使用 PHP 完全删除标签;但我已经设计了它,只想禁用它。是否可以?

回答by Pekka

Nope, there is no CSS-only way known to me to disable a link the way you describe.

不,我不知道仅使用 CSS 的方法可以按照您描述的方式禁用链接。

The only thing that comes to mind is putting an additional, transparent element in front of the link, but that can't be achieved in pure CSS, either.

唯一想到的是在链接前放置一个额外的透明元素,但这在纯 CSS 中也无法实现。

How about giving it a href='#' onclick='return false'when generating them in PHP?

href='#' onclick='return false'在 PHP 中生成它们时给它一个怎么样?

回答by Gabriel

you could also use the css property display:none;

你也可以使用 css 属性 display:none;

回答by Denish Vachhani

you can try this

你可以试试这个

a.disabled_class_name{
    pointer-events: none;
    cursor: default;
}