Reputation: 99
I have a page with popup window. when popup window is open it has some buttons with class of 'ui-state-disabled'. and if someone trying to click outside of popup box i want to close/hide that box ONLY if button has classname of 'ui-state-disabled'. but some times popup box has several buttons with 'ui-state-disabled' class, in that case if the 'ui-state-disabled' count is 1 popup can close by clicking outside.
below is my code. and its not working when multtiple buttons has 'ui-state-disabled' class. please advice
$(document).on('click', function (e) {
if (($(e.target).closest(".classChapter").length === 0)) {
if ($('div.buttonclass').hasClass('ui-state-disabled') === true) {
//close a dialog box
} else {
console.log(2);
}
}
});
Upvotes: 0
Views: 225
Reputation: 1674
your second if
if ($('div.buttonclass').hasClass('ui-state-disabled') === true) {
can be
if ($('div.buttonclass.ui-state-disabled').length === 1) {
Upvotes: 1