jQuery 单击时删除 html 图像上的蓝色突出显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16432909/
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
Remove blue highlight over html image when clicked
提问by Vinraj
I am making a custom Application in Android. I am displaying a html page with an img tag inside a div.
我正在 Android 中制作自定义应用程序。我在 div 中显示一个带有 img 标签的 html 页面。
<div class="press">
<img src="but.png" width="150" height="62" border="0"/>
</div>
In the javascript I am writing:
在我写的javascript中:
$(".press").bind("click",function()
{
//display something
});
When I click on the image, the click is working but the image is surrounded with a blue overlay.
当我点击图像时,点击有效,但图像被蓝色覆盖物包围。
I dont understand how to remove it. I have tried many ways but none of the answers work. Please help. Thanks
我不明白如何删除它。我尝试了很多方法,但没有一个答案有效。请帮忙。谢谢
回答by Parthik Gosar
You can prevent selection on your page through css. You can change the * selector to the element selector you want to prevent from selection.
您可以通过 css 阻止在您的页面上进行选择。您可以将 * 选择器更改为要阻止选择的元素选择器。
/*IE9*/
*::selection
{
background-color:transparent;
}
*::-moz-selection
{
background-color:transparent;
}
*
{
-webkit-user-select: none;
-moz-user-select: -moz-none;
/*IE10*/
-ms-user-select: none;
user-select: none;
/*You just need this if you are only concerned with android and not desktop browsers.*/
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
input[type="text"], textarea, [contenteditable]
{
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
回答by Rohan Kumar
Try this:
尝试这个:
CSS
CSS
.press, img, .press:focus, img:focus{
outline: 0 !important;
border:0 none !important;
}
回答by Sacha Nacar
You could use CSS:
你可以使用 CSS:
** HTML **
** HTML **
<button class="press">
<img src="but.png" width="150" height="62" border="0"/>
</button>
** CSS **
** CSS **
.press{
outline-width: 0;
}
.press:focus{
outline: none;
}
Answer take from here: How to remove the border highlight on an input text element
回答从这里获取:如何删除输入文本元素上的边框突出显示
回答by Ayush
It may be the background color or the border color on the div that includes the button. Else use a code like following to remove the css after click completely
它可能是包含按钮的 div 上的背景颜色或边框颜色。否则使用如下代码完全点击后删除css
$("#myButton").click(function(){
$("#displayPanel div").removeClass('someClass');
});