<div id = "div1" onclick = "showDiv()">你好</div>
<div id = "div2" onblur = "hiddenDiv()" tabindex="0">查看</div>
function showDiv()
{
document.getElementById("div2").style.display="";
document.getElementById("div2").focus();
}
function hiddenDiv()
{
document.getElementById("div2").style.display="none";
}
代码如上,但在页面上显示时,会有虚线,如何让虚线去掉?
------解决方案--------------------
原因是节点获取了焦点会出现外边框。所以你去除外边框样式即可:<div id = "div2" onblur = "hiddenDiv();" tabindex="0" style="outline: none" >查看</div>