<
>

Jquery 实现弹出层插件

2019-07-15 10:43:26 来源:易采站长站 作者:王旭


//根据传入数据,添加遮罩层,弹出提示框
    function xsMain(title, width, height, tag, close, mainContent) {
        var divmask = "<div class="mask"></div>";
        $(mainContent).append(divmask);
        var xsPop1 = " <div id="xsPop" class="PopUp"> <div class="PopHead" id="xsPopHead">";
        var xsPop2 = " <b>" + title + " </b><span id="xsColse">" + close + "</span>";
        var xsPop3 = "  </div>  <div class="PopMain" id="xsPopMain">";
        var xsPop5 = "</div><span id="xytest"></span> </div>";
        var allHtml = xsPop1 + xsPop2 + xsPop3 + xsPop5;
        $(mainContent).append(allHtml);
        $(tag).show();
        $(tag).appendTo("#xsPopMain");
        //得到浏览器的高度和宽度,进行后面判断(高度超过,拖动边框限制)
        clientHeight = window.screen.height;
        clientWidth = window.screen.width;
        if (height > clientHeight) {
            height = clientHeight - 100;
        }
        if (width > clientWidth) {
            width = clientWidth - 100;
        }
        $("#xsPop").css({
            "heigth": height + "px",
            "width": width + "px",
            "margin-top": "-" + (height / 2) + "px",
            "margin-left": "-" + (width / 2) + "px"
        });
        $("#xsPopMain").css("height", height - $("#xsPopHead").height());
        xsdrag("#xsPopHead", "#xsPop"); //绑定拖动动作
        $("#xsColse").bind("click", function () { ClosePop(tag, mainContent); }); //绑定关闭动作
    }

  4:关闭动作

这里要先把tag给容器,不然后面remove时会一起remove,第二次弹出就找不到tag了。

暂时禁止评论

微信扫一扫

易采站长站微信账号