// I am trying to apply an "onfocus="this.blur();"" so as to remove the dotted border lines around pics that are being clicked-on
// the effect should be applied to all thumb-nail links/a-tags within a div..
// sudo code (where I am):
$(".box a").focus( // so as to effect only a tags within divs of class=box | mousedown vs. onfocus vs. *** ?? | javascript/jquery... ???
function ()
{
var num = $(this).attr('id').replace('link_no', '');
alert("Link no. " + num + " was clicked on, but I would like an onfocus=\"this.blur();\" effect to work here instead of the alert...");
// sudo bits of code that I'm after:
// $('#link_no' + num).blur();
// $(this).blur();
// $(this).onfocus = function () { this.blur(); };
}
);
// the below works for me in firefox and ie also, but I would like it to effect only a tags within my div with class="box"
function blurAnchors2()
{
if (document.getElementsByTagName) {
var a = document.getElementsByTagName("a");
for (var i = 0; i < a.length; i++) {
a[i].onfocus = function () { this.blur(); };
}
}
}发布于 2010-03-15 20:46:09
谢谢你们--我已经找到了css(a:focus):
img, a:focus{
outline: none;
}对我来说,它似乎工作正常( the键仍然有效,点击时边框消失了)。在ie和火狐中都有。现在必须翻新一些其他链接才能使用它。
再次感谢。
发布于 2010-03-15 19:44:28
不建议进行模糊处理。如果你想做的就是隐藏焦点线,那就用下面的代码:
a[i].onfocus = function () { this.hideFocus = true; };这将适用于所有版本的IE。对于其他浏览器(包括标准模式下的IE8 ),您可以设置outline CSS样式以隐藏焦点轮廓:
a {
outline: none;
}这将使您的页面比在获取焦点时模糊元素的键盘友好得多。
发布于 2010-03-15 19:49:09
我建议只使用CSS来删除边框。
img, a:active{
outline: none;
}或者一定要使用JS有什么特别的原因?
https://stackoverflow.com/questions/2446769
复制相似问题