开发者

jQuery dialog: Alternate close button

How can I define an alternate close button for jQuery dialog?

I want an anchor with the class "popup-close" to close the open dialo开发者_C百科g.

Simplest is best!


This should do the trick:

<div id="dialog" title="Dialog Title" style="border: 1px solid red; position: absolute; display: none">
    I'm in a dialog
    <span class="popup-close">CLOSE ME!</span>
</div>

<a id="open-dialog-button" href="#">Open Dialog</a>

And your jQuery...

$("#dialog > .popup-close").click(function () {
    $("#dialog").dialog("close");
});

$("#open-dialog-button").click(function () {
    $("#dialog").dialog({
        // Disable close on escape and the default close button for this dialog.
        closeOnEscape: false,
        open: function(event, ui) {
            $(".ui-dialog-titlebar-close", $(this).parent()).hide();
        }
    });
}); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜