I am using this script to find an a href within a parent element and then go to that link if the parent div is clicked.
jQuery(".card").click(function() {
  window.location = jQuery(this).find("a").attr("href"); 
  return false;
});
However, I am finding that if there is no a href at all, it is still adding a link to 'undefined' (resulting in 404).
I am fairly certain I need an if to detect if there is an a href, but cannot get it to work:
jQuery(".card").click(function() {
     if (jQuery(this).find("a").attr("href").length {
  window.location = jQuery(this).find("a").attr("href"); 
  return false;
  }
});
 
    