如何点击按钮显示一个DIV,点击页面其它地方隐藏这个DIV?

wang_solaris wang_solaris 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
页面上有个按钮,默认有个DIV是隐藏起来的。我是这样写的:

function ShowFinishEditor(left, top) {
var obj = document.getElementById('divFinishEditor');
if (obj == null)
return false;
obj.style.display = '';
obj.style.posLeft = left;
obj.style.posTop = top;

return false;
}

function HideFinishEditor() {
var obj = document.getElementById('divFinishEditor');
if (obj == null)
return false;
obj.style.display = 'none';
}

document.onclick = HideFinishEditor;
document.getElementById('button1').onclick="ShowFinishEditor(this.getBoundingClientRect().left, this.getBoundingClientRect().top+this.offsetHeight);"

怎么每次点击按钮的时候总要先调用ShowFinishEditor然后又调用HideFinishEditor啊?所以每次都显示不出来。怎么办?
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
wang_solaris
JavaScript 87,984 成员 224,681 内容