jquery check if element has parent with id 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"
}