If #box doesn’t have a containing div with a class of current-map, then do something.
I thought the ! would have worked but it doesn’t.
if (!$('#box').closest('.current-map')) {
//do something
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could check the length of the resulting selection. If it’s
0, there was no ancestor.current-mapelement:Your attempt does not work because most jQuery methods will return an instance of jQuery whether it contains any DOM elements or not, and that will always evaluate to
true.