1

我是 Jquery 的新手,我正在尝试使用 div 容器来加载 URL,但是,我想为用户提供一个选项,可以在右上角使用 X 符号关闭它,就像在 Amazon.com 中一样。实现这一目标的最佳方法是什么?

这是我所拥有的,并且似乎笨拙地找出右上角的位置并放置图像 X:

$("#url_link_details").click(function() {
    $("#details").load("tooltip_address.htm", function() {
        $(this).addClass("openwindow").show();
        $(".img_close").addClass("img_close_show").show();
    })
});

任何帮助表示赞赏。

4

1 回答 1

2

一些html:

<div id="popup">
    <img src="x.gif" alt="Close" class="img_close" />
    <div class="details"></div>
</div>

一些CSS:

#popup .img_close {
    float: right;
}

#details {
    clear: right; /* if you want there to be a "titlebar" area */
}

一些 jQuery

$('#url_link_details").click(function() {
    $('#details').load('tooltip_address.htm', function() {
        $('#popup')
            .show()
            .find('.img_close')
            .click(function() {
                $('#popup').hide();
            })
        ;
    })
})
于 2008-11-06T01:05:21.213 回答