Jquery destroy dialog box after x seconds
Question
How can I destroy a dialog box after a certaing amount of seconds?????
This is my code:
<script type="text/javascript">
$(function() {
$(".dialog-message").dialog({
modal: true,
buttons: {
Ok: function() {
$(this).dialog('close');
}
}
});
});
</script>
Solution
$(function() {
var dialog = $(".dialog-message").dialog({
modal: true,
buttons: {
Ok: function() {
$(this).dialog('close');
}
}
});
setTimeout(function(){
dialog.dialog('destroy');
},5000); // 5 seconds
});
OTHER TIPS
function destroyDialog() {
$(".dialog-message.").dialog("destroy");
}
setTimeout("destroyDialog()", 1000);
This does it after 1 second, 1000 milliseconds...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow