开发者

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.


  1. Attach an event hanlder to the popup element. On click of that stop event bubbling.

  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜