Closing all jquery dialog windows in JavaScript

Matthew Rygiel picture Matthew Rygiel · Oct 7, 2010 · Viewed 22.7k times · Source

How does one close all jquery ui dialog windows in javascript?

Situation:

The page has multiple things that can be opened using the dialog boxes. I need a way to close all previous windows before opening a new one.

Answer

Nick Craver picture Nick Craver · Oct 7, 2010

They all have the .ui-dialog-content class, so select by that and close them, like this:

$(".ui-dialog-content").dialog("close");