Hide burger menu on click

This code below should close the burger menu on click in mobile view (when clicked on a menu item with anchor link)

add_action( 'wp_footer', 'hide_burger' );
function hide_burger() {
<script type="text/javascript">
$('#menu-menu-new-ps-works-1 a').click(function(){

Although the menu scrolls down to the section, it is closing for an instant and then reloads again.