开发者

jQuery dialog: Alternate close button

开发者 https://www.devze.com 2023-01-10 02:01 出处:网络
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.

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

精彩评论

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

关注公众号