jquery if has parent 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"
}