javascript 单击时如何删除“虚线边框”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4374622/
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
How to remove the "Dotted Border" on clicking?
提问by 5416339
As you can see
如你看到的


I want to somehow remove the dotted lines after the button has been clicked.Any ideas how ?
单击按钮后,我想以某种方式删除虚线。任何想法如何?
Thanks
谢谢
GUYS : This is the current status of my CSS ansd HTML but still no USE:
伙计们:这是我的 CSS ansd HTML 的当前状态,但仍然没有使用:
.myButton input {
position:absolute;
display:block;
top: 5%;
left:87%;
height: 44px;
border:none;
cursor:pointer;
width: 43px;
font: bold 13px sans-serif;;
color:#333;
background: url("hover.png") 0 0 no-repeat;
text-decoration: none;
}
.myButton input:hover {
background-position: 0 -44px;
color: #049;
outline: 0;
}
.myButton input:active {
background-position: 0 -88px;
color:#fff;
outline: 0;
}
input:active, input:focus {
outline: 0;
}
<div class="myButton">
<input type="submit" value="">
</div>
Nothing seems to be happening !!
好像什么都没发生!!
采纳答案by Shadow Wizard is Ear For You
Possible with pure HTML as well:
也可以使用纯 HTML:
<a href="..." hidefocus="hidefocus">...</a>
And with JavaScript you can do that on all links:
使用 JavaScript,您可以在所有链接上执行此操作:
window.onload = function WindowLoad(evt) {
//hide focus:
var arrLinks = document.getElementsByTagName("a");
for (var i = 0; i < arrLinks.length; i++) {
arrLinks[i].hideFocus = "true";
}
回答by Linus Kleen
You have to style the <a>like:
你必须<a>这样设计:
a {outline: none}
回答by kobe
use the below code
使用下面的代码
a:active
{
outline: none;
}
try for other browsers also
也尝试其他浏览器
a:focus
{
-moz-outline-style: none;
}
a:focus { outline:none }
回答by Shikiryu
Despite my comment on your question,
尽管我对你的问题发表评论,
You should keep them for accessibility.
您应该保留它们以方便访问。
You can find your CSS-trick here for this
(Anyway, you should keep them.)
(无论如何,你应该保留它们。)
回答by danieelito
#myElement { outline: 0; }
Try this on your element, i dont now if is an image, div, button, link. But it works
在你的元素上试试这个,如果是图像、div、按钮、链接,我现在不知道。但它有效
回答by bibaso
If you want to keep the outline on active and on focus, but hide it on clicking a link, you can add in css:
如果您想让大纲保持活动状态和焦点,但在单击链接时隐藏它,您可以添加 css:
A.No-Outline {outline-style:none;}
A.No-Outline {outline-style:none;}
and use script:
并使用脚本:
$('A').hover(function() {
$(this).addClass('No-Outline');
},function() {
$(this).removeClass('No-Outline');
});
you must be hover befor clicking, so it does the job.
你必须在点击之前悬停,所以它可以完成工作。

