0

I want a WP page to scroll to certain class according to day of the week. On each day I want the users browsers to scroll to the current day and on Sunday to go to Monday.

HTML added to a WordPress page

<h2>Activities</h2>
<ul>
   <li><span class="monday">Monday</span>xyz</li>  
   <li><span class="tuesday">Tuesday</span>xyz</li>
   <li><span class="wednesday">Wednesday</span>xyz</li>
   <li><span class="thursday">Thursday</span>xyz</li>
   <li><span class="friday">Friday</span>xyz</li>
   <li><span class="saturday">Saturday</span>xyz</li>    
</ul> 

I know I need the getDay JS to determine the current day, but I have a hard time getting the page to scroll. Any help would be greatly appreciated. Thanks in advance! vik3d

Devnsyde
  • 1,213
  • 1
  • 11
  • 28
vik3d
  • 3
  • 2

1 Answers1

0

See if this helps: https://jsfiddle.net/y3llowjack3t/rephuby3/

$("#button").click(function() {
    $('html, body').animate({
        scrollTop: $(".wednesday").offset().top
    }, 2000);
});

See this link for more help on the subject: jQuery scroll to element

Update:

To scroll on load see: https://jsfiddle.net/y3llowjack3t/rephuby3/1/

To scroll based on weekday name: https://jsfiddle.net/y3llowjack3t/rephuby3/3/

Community
  • 1
  • 1
Devnsyde
  • 1,213
  • 1
  • 11
  • 28