HTML-如何禁用& lt; a href& gt ;? [英] Html- how to disable <a href>?
本文介绍了HTML-如何禁用& lt; a href& gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个按钮,可以在单击时打开模式窗口.
I created a button that open a modal window on click.
<a href="#" data-toggle="modal" data-target="#myModal" class="signup-button gray-btn pl-pr-36" id="connectBtn" data-role="disabled">Connect</a>
由于某些原因, data-role =已禁用"
不能正常工作.如何禁用它?
For some reason the data-role="disabled"
doesn't work good.
How can I disable it?
推荐答案
您可以使用CSS完成此操作:
You can use CSS to accomplish this:
.disabled {
pointer-events: none;
cursor: default;
}
<a href="somelink.html" class="disabled">Some link</a>
或者您可以使用JavaScript阻止类似这样的默认操作:
Or you can use JavaScript to prevent the default action like this:
$('.disabled').click(function(e){
e.preventDefault();
})
这篇关于HTML-如何禁用& lt; a href& gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文