1

私は Jquery を初めて使用し、div コンテナーを使用して URL をロードしようとしていますが、Amazon.com のように右上隅にある X 記号で閉じるオプションをユーザーに提供したいと考えています。これを達成するための最良の方法は何ですか?

これが私が持っているもので、右上隅がどこにあるかを把握して画像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 に答える