How do I remove the close button (the X in the top-right corner) on a dialog box created by jQuery UI?
$("Selector"). dialog({ open: function () { $(". ui-dialog-titlebar-close"). hide(); } });
You cannot hide the close button of a pop-up window. If you want that sort of control, don't use a window. This you can style as you want, and the content you show in window. open you can present to the user in an iframe inside the dialog.
Close Dialog when clicking outside of its region in JavaScript Dialog control. By default, dialog can be closed by pressing Esc key and clicking the close icon on the right of dialog header. It can also be closed by clicking outside of the dialog using hide method.
I have found this worked in the end (note the third line overriding the open function which find the button and hides it):
$("#div2").dialog({ closeOnEscape: false, open: function(event, ui) { $(".ui-dialog-titlebar-close", ui.dialog || ui).hide(); } });
To hide the close button on all dialogs you can use the following CSS too:
.ui-dialog-titlebar-close { visibility: hidden; }
Here is another option just using CSS that does not over ride every dialog on the page.
The CSS
.no-close .ui-dialog-titlebar-close {display: none }
The HTML
<div class="selector" title="No close button"> This is a test without a close button </div>
The Javascript.
$( ".selector" ).dialog({ dialogClass: 'no-close' });
Working Example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With