Jquery destroy dialog after x seconds

How can I destroy the dialog after confirming the number of seconds?

This is my code:

<script type="text/javascript">
 $(function() {
  $(".dialog-message").dialog({
   modal: true,
   buttons: {
    Ok: function() {
     $(this).dialog('close');
    }
   }
  });
 });

 </script>
+5
source share
2 answers
$(function() {
var dialog = $(".dialog-message").dialog({
    modal: true,
    buttons: {
        Ok: function() {
            $(this).dialog('close');
        }
    }
});

setTimeout(function(){
    dialog.dialog('destroy');
},5000); // 5 seconds
});
+4
source
 function destroyDialog() {
      $(".dialog-message.").dialog("destroy");
 }

 setTimeout("destroyDialog()", 1000);

This happens after 1 second, 1000 milliseconds ...

0
source

All Articles