facetwp make result in layout builder clickable

/**
 ** adds click even to each facetwp layout builder result to trigger 
 ** a click on the first link within the result
 **/
add_action( 'wp_footer', function() {
  ?>
  <script>
  (function($) {
    $( '.facetwp-template' ).on( "click", ".fwpl-result", function() {
      $(this).find('a:first')[0].click();
    });
  })(jQuery);
  </script>
  <?php
});