如何点击按钮显示一个DIV,点击页面其它地方隐藏这个DIV?
页面上有个按钮,默认有个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啊?所以每次都显示不出来。怎么办?