facetwp link all with js

<?php

/** adds js to make a layout builder results section link to the post link.  The post link needs to be 
 ** used to link an item within the results **/
add_action( 'wp_footer', function() { ?>
    <script>
        (function($) {
            $( ".facetwp-template" ).on( "click", ".fwpl-result", function() {
                window.location.href = $(this).find('a').attr("href");
            });
        })(jQuery);
    </script>
<?php });