繁体   English   中英

如何使用jquery在鼠标上正确显示弹出窗口

[英]How to display the pop up correctly on mouse over using jquery

正如你在我的样本中看到的那样,我的弹出窗口显示在边缘。 如何检查边缘,从而在右侧显示弹出窗口。

弹出窗口显示在屏幕的末尾

另一个例子就是这个。 这个显示了底部的弹出窗口。 我希望它显示完整弹出窗口将显示。

在此输入图像描述

您可以在www.mydubaitrip.com/restaurants.aspx查看实际演示

我的代码是这样的

$(".thumbsUpNav").live("mouseenter", function(e) {
    var id = $(this).children("span").attr("id");
    var pURL = $('#txtTopLevelNode').val() + 'WhyBookList.aspx?id=';
    pID = "#whyBookReviewRating" + id;
    $(".whyBookReviewRating").css({"display":"none"});
    //$(this).children('.arrow_pop_up').css({top: $(this).offset().top + "px"});

    if (id != "") {
        $(pID).empty();
        if (($(pID).length == 0) || ($(pID).length == 1)) {

            $.ajax({
                contentType: 'application/json; charset=utf-8',     
                type: 'GET',
                url : pURL + id.substring(1, 6) + '&type=' + id.substring(0,1),
                success : function (data) {
                    $(pID).append(data);
                }
            });
        }  
        pos = $(this).offset();    
        var width = $(this).children("span").width();     

        $(pID).css({   
            left: (width) + 'px'
        });
        $(pID).stop().css({"display":"block"});  
    }
    else if (id == "") {
        $(".whyBookReviewRating").css({"display":"none"}); 
    }
});

$(".thumbsUpNav").live("mouseleave", function() {
    var id = $(this).attr("rel");
    pID = "#whyBookReviewRating" + id;
    $(".whyBookReviewRating").css({"display":"none"});  
});

页面右侧没有足够的空间位于www.mydubaitrip.com/restaurants.aspx

手形图标位于页面的最右端,如果您在其中添加任何内容,则会出现水平滚动! 你为什么要在没有足够空间的情况下让盒子出现在那只手的右侧?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM