How to add JS snippet before closing tag?

Ahh, solved it with this!

add_action( 'wp_head', 'jQuery_UI_Tabs' );
function jQuery_UI_Tabs() {
if ( is_page_template('course-landing-page.php' ) ) {
    echo'<script>
            $(function() {
                $( "#tabs" ).tabs();
            });
        </script>';
}