Detect if a jQuery UI dialog box is open
问题 I am using a jQuery UI dialog. If it is open, I want to do one thing. If it is closed, I want to do another. My question is, how do I detect if a jQuery UI dialog box is open or not? 回答1: If you read the docs. $('#mydialog').dialog('isOpen') This method returns a Boolean (true or false), not a jQuery object. 回答2: Actually, you have to explicitly compare it to true. If the dialog doesn't exist yet, it will not return false (as you would expect), it will return a DOM object. if ($('#mydialog')