Could someone please explain me why replacing the following
$('.post_title a').hover(function () {
$(this).parent().parent().parent().parent().find(".post_footer").toggleClass('footer_border')
});
with
$('.post_title a').hover(function () {
$(this).closest(".post_footer").toggleClass('footer_border')
});
doesn’t work??
Look at the documentation for
.closest(). It states that:Since the element you’re looking for isn’t an ancestor of your link, it won’t work. To achieve what you need, you could use this instead: