-3

I want some specific content to be added to my website to be added automatically at certain times of the year? What shall I add to my code to make this possible?

Here is the code that i want top be edited :

 <div class="event-table">
        <ul class="content-box-list events" data-id="314324">
        <li data-id="701207" class="first">
                <span class="date" data-unix-date="1556078400" data-time="">Wed, Apr<br><strong>24</strong></span>
                <span class="title">8th Grade Class Fundraising Meeting</span>
                <span class="see-details">See Details</span>
        </li>

        <li data-id="735125">
                <span class="date" data-unix-date="1556769600" data-time="">Thu, May<br><strong>2</strong></span>
                <span class="title">Spring Band Concert Dress Rehearsal</span>
                <span class="see-details">See Details</span>
        </li>

        <li data-id="735135">
                <span class="date" data-unix-date="1556769600" data-time="">Thu, May<br><strong>2</strong></span>
                <span class="title">Spring Band Concert </span>
                <span class="see-details">See Details</span>
        </li>

        <li data-id="815524">
                <span class="date" data-unix-date="1557720000" data-time="">Mon, May<br><strong>13</strong></span>
                <span class="title">Board of Education Meeting</span>
                <span class="see-details">See Details</span>
        </li>

        <li data-id="698413" class="last">
                <span class="date" data-unix-date="1557892800" data-time="">Wed, May<br><strong>15</strong></span>
                <span class="title">PTO Meeting</span>
                <span class="see-details">See Details</span>
        </li>
    </ul>
     </div>   
Omar-JR
  • 15
  • 1
  • 6

1 Answers1

0

If i understood your question correctly, you want to add content to your site on a certain day(s), you can achieve this with Javascript by determining the current date and then writing some if clauses to do a certain thing when it meets criteria, e.g if you want to display a message today then you could do this:

  var today = new Date();
  var dd = String(today.getDate()).padStart(2, '0');
  var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  var yyyy = today.getFullYear();
  today = mm + '/' + dd + '/' + yyyy;
  if(today == '04/19/2019') {
      alert('do this');
      $('.yourClass').show(); //show content
      $('.yourOtherClass').hide() //hide content
  }

Edit: You can also determine the day of the week & time of day if you need to be more specific.

Jenko
  • 190
  • 8
  • it don't work i tried but nothing changes – Omar-JR Apr 19 '19 at 18:24
  • I've tested this and it works fine, as long as you 'display: none' on the class you want to hide until the specific date, and reference the class of that element in the code i have shared, this will work. – Jenko Apr 19 '19 at 22:27
  • Can you show me how did you write it please – Omar-JR Apr 19 '19 at 22:35
  • Just seen what the issue was my apologies. If you switch the date criteria '19/04/2019' so that the format is instead '04/19/2019', this will work for you. – Jenko Apr 19 '19 at 22:44
  • ooooo yes just saw that okay let me try it – Omar-JR Apr 19 '19 at 22:47
  • I don't know what s happening – Omar-JR Apr 19 '19 at 22:57
  • Can you put alert('this working?'); in the IF statement to see if it's triggering on page load? – Jenko Apr 19 '19 at 22:58
  • Can you give me a wider example make a class your self and make it disappear and the other one appears – Omar-JR Apr 19 '19 at 22:58
  • I have created this fiddle for you to take a look at: https://jsfiddle.net/h05n8mo2/10/ the only difference i can see is that you might not be referencing an external jquery script on your site. – Jenko Apr 19 '19 at 23:08
  • Created a new fiddle, please use the one edited in the above – Jenko Apr 19 '19 at 23:09
  • Did this work for you? – Jenko Apr 19 '19 at 23:30
  • No look https://jsfiddle.net/6eLnt5qr/7/ – Omar-JR Apr 19 '19 at 23:38
  • Okay I can't concentrate now it's 1am I will sleep and it will be really kind if you added the time for me as I need time and sorry for asking you so much questions for a code like this . I appreciate your work a lot you code got no problem I just have to see my code and fix it I will do this when I wake up . Thanks alot for your help your a great person thanks alot . – Omar-JR Apr 19 '19 at 23:45
  • I have fixed your fiddle, you had created the classes however they are case sensitive, so you were referencing something that didn't exist. Please see your amended link https://jsfiddle.net/6rquf2n9/1/ – Jenko Apr 19 '19 at 23:55