check if parent exists jquery code example
Example: jquery if has parent
if ($(this).parents('.last').length) {
// element has an ancestor element with the class "last"
}
if ($(this).parents('.last').length) {
// element has an ancestor element with the class "last"
}