码迷,mamicode.com
首页 > Web开发 > 详细

Js popup position which right under target item

时间:2015-07-20 12:45:32      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

    <div style="margin-left:100px;">
        <span id="txt" style="color:#eeeeff;abc</span>
            
        <div id="divPop" style="z-index:500;position:absolute;display:none;color:#ffffff;background-color:#000000">
            Hello World! This is Popup Div.
        </div>
    </div>
    jQuery.fn.popupDiv = function (divToPop) {
        var pos=$(this).position();
        var height = $(this).height;

        $(this).click(function (e) {
            $(divToPop).css({
                left: pos.left + "px",
                top: (pos.top + height) + "px"
            });
            if ($(divToPop).css(‘display‘) !== ‘none‘) {
                $(divToPop).hide();
            }
            else {
                $(divToPop).show();
            }
        });
    };

        $(document).ready(function() {
            $("#txt").popupDiv("#divPop");
        });

 

Js popup position which right under target item

标签:

原文地址:http://www.cnblogs.com/webglcn/p/4660859.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!