Open tab on current day problem jQuery and WordPress

I need to create a tab on custom page template that open the tab in relatinship current day.

This is my template page

<?php
/* Template Name: Palinsesto */
get_header();


?>

<div class="td-main-content-wrap">
    <div class="td-container <?php echo $td_sidebar_position; ?>">
        <div class="td-crumb-container">
            <?php echo td_page_generator::get_page_breadcrumbs(get_the_title()); ?>
        </div>
        <div class="td-pb-row">
            <?php
            switch ($loop_sidebar_position) {
                default:
                    ?>
                        <div class="td-pb-span8 td-main-content" role="main">
                            <div class="td-ss-main-content">
                                                            <?php
                                if (have_posts()) {
                                    while ( have_posts() ) : the_post();
                                        ?>
                                        <div class="td-page-header">
                                            <h1 class="entry-title td-page-title">
                                                <span><?php the_title() ?></span>
                                            </h1>
                                        </div>
                                        <div class="td-page-content">
                                       <?php
                                            the_content();
                                    endwhile;//end loop
                                }
                                ?>

                                 <div class="tabs">
        <ul class="tabNavigation">
            <li><a href="#monday">Monday</a></li>
            <li><a href="#tuesday">Tuesday</a></li>
            <li><a href="#wednesday">Wednesday</a></li>
            <li><a href="#thursday">Thursday</a></li>
            <li><a href="#friday">Friday</a></li>
            <li><a href="#saturday">Saturday</a></li>
            <li><a href="#sunday">Sunday</a></li>
        </ul>
        <div id="monday">
            <h2>Monday</h2>
            <p>monday ...</p>
        </div>
        <div id="tuesday">

            <h2>Tuesday</h2>
            <p>tuesday ...</p>
        </div>
        <div id="wednesday">
            <h2>Wednesday</h2>
            <p>wednesday ...</p>
        </div>
        <div id="thursday">
            <h2>Thursday</h2>
            <p>thursday ...</p>
        </div>
        <div id="friday">
            <h2>Friday</h2>
            <p>friday ...</p>
        </div>
        <div id="saturday">
            <h2>Saturday</h2>
            <p>saturday ...</p>
        </div>
          <div id="sunday">
            <h2>Sunday</h2>
            <p>sunday ...</p>
        </div>
    </div>
<!--<ul class="tab">
  <li><a href="javascript:void(0)" class="tablinks" onclick="openCity(event, 'London')">London</a></li>
  <li><a href="javascript:void(0)" class="tablinks" onclick="openCity(event, 'Paris')">Paris</a></li>
  <li><a href="javascript:void(0)" class="tablinks" onclick="openCity(event, 'Tokyo')">Tokyo</a></li>
</ul>

<div id="London" class="tabcontent">
  <h3>London</h3>
  <p>London is the capital city of England.</p>
</div>

<div id="Paris" class="tabcontent">
  <h3>Paris</h3>
  <p>Paris is the capital of France.</p> 
</div>

<div id="Tokyo" class="tabcontent">
  <h3>Tokyo</h3>
  <p>Tokyo is the capital of Japan.</p>
</div>        -->
                                </div>
                            </div>
                        </div>
                        <div class="td-pb-span4 td-main-sidebar" role="complementary">
                            <div class="td-ss-main-sidebar">
                                <?php get_sidebar(); ?>
                            </div>
                        </div>
                    <?php
                    break;
            }
            ?>
        </div> <!-- /.td-pb-row -->
    </div> <!-- /.td-container -->
</div> <!-- /.td-main-content-wrap -->
    <?php
get_footer();

I put here this code about tab of weekdays

                   <div class="tabs">
<ul class="tabNavigation">
    <li><a href="#monday">Monday</a></li>
    <li><a href="#tuesday">Tuesday</a></li>
    <li><a href="#wednesday">Wednesday</a></li>
    <li><a href="#thursday">Thursday</a></li>
    <li><a href="#friday">Friday</a></li>
    <li><a href="#saturday">Saturday</a></li>
    <li><a href="#sunday">Sunday</a></li>
</ul>
<div id="monday">
    <h2>Monday</h2>
    <p>monday ...</p>
</div>
<div id="tuesday">

    <h2>Tuesday</h2>
    <p>tuesday ...</p>
</div>
<div id="wednesday">
    <h2>Wednesday</h2>
    <p>wednesday ...</p>
</div>
<div id="thursday">
    <h2>Thursday</h2>
    <p>thursday ...</p>
</div>
<div id="friday">
    <h2>Friday</h2>
    <p>friday ...</p>
</div>
<div id="saturday">
    <h2>Saturday</h2>
    <p>saturday ...</p>
</div>
  <div id="sunday">
    <h2>Sunday</h2>
    <p>sunday ...</p>
</div>

After on functions.php i’ve add this script code

 /* Date Current */

 function wpse203799_footerscript(){
 ?>
<script type="text/javascript">
$(function() {
    var tabContainers = $('div.tabs > div');
    $('div.tabs ul.tabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();

        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');

        return false;
    }).eq((new Date().getDay() || 7) - 1).click();
});
</script>
 <?php
add_action( 'wp_footer', 'wpse203799_footerscript', '30' ); }?>

But not work. I display a simple list and not a tab. I also try to put

<script>
$(function() {
    var tabContainers = $('div.tabs > div');
    $('div.tabs ul.tabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();

        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');

        return false;
    }).eq((new Date().getDay() || 7) - 1).click();
});

Direct on page custom before ?> on close header but nothing change. Where wrong? Thanks

Solutions Collecting From Web of "Open tab on current day problem jQuery and WordPress"

Your problem is one of formatting:

 <?php
add_action( 'wp_footer', 'wpse203799_footerscript', '30' ); }?>

There’s a very good reason that programmers follow coding standards, and use editors that automatically format and indent code. If we do these to the code used here, we’ll see this:

    <?php
    add_action( 'wp_footer', 'wpse203799_footerscript', '30' );
}
?>

This means that the function is never hooked into wp_footer because the add_action call is inside the function. The only way to hook it with the code written like this is to call the function itself, which is not what you want.

Instead, move the add_action call outside of the function so that it’s always called