disable background in jquery popup

你离开我真会死。 提交于 2019-12-23 01:17:08

问题


OK, So i have this snippet http://jsfiddle.net/8vFEd/ here;

whenever the popup comes up, I either want to disable the background, so that users can't click on another language until they close the first popup, or how would I accomplish that, whenever users click on second language, the first popup disappears and its corresponding popup appears.


回答1:


My suggestion would be to put an overlay over the background which will "catch" clicks through to the rest of the page. Add the following to your $('.prop a').click() function, before the <div class='lang'> append call:

$("body").append('<div class="modalOverlay">');

and this to your css:

.modalOverlay {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0px;
    left: 0px;
    background-color: rgba(0,0,0,0.3); /* black semi-transparent */
}

Then in your code for handling "close" clicks, remove this .modalOverlay from the DOM. Remember to add the overlay before your popup window so it sits behind the window (or add "z-index: 5" to your overlay css and "z-index: 6" to your popup css)

I would also suggest modifying your .lang css rule to be position: absolute; or fixed instead of relative.




回答2:


Add this at beginning of your onclick

$(".lang").remove();

That will remove or clear the div with lang class before repainting the DOM with a new one.



来源:https://stackoverflow.com/questions/7185469/disable-background-in-jquery-popup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!