implementing show/hide popup box on mouse click
I have implented the show part properly. But how to implement the hide of popup on click of anything on the page? And moreover there is a link, on click of which this will expand and collapse开发者_运维问答 also.
Any help. Thanks.
Attach an event hanlder to the popup element. On click of that stop event bubbling.
Attach an event handler to document. On click of that hide the popup.
A sample using jQuery
Updated sample
function switchElement(elementId) {
if(document.getElementById(elementId).style.display=="")
{
document.getElementById(elementId).style.display="none";
}
else
{
document.getElementById(elementId).style.display="";
}
}
expand added to Webbisshh's code.
why don't you try this.
function close() {
document.getElementById("popupBox").style.display="none";
}
In onclick handler, call the above function. For expand and collapse, Mootools provides very simple implementation check it.
精彩评论