JSFiddle - React, Tailwind, and code Playground

by yosafatade

HTML

<div id="accordion">
</div>

JavaScript

$(function() {
    var d = new Date();
    var yr = Number(d.getFullYear());
    var mo = d.getMonth()+1;
    var month=new Array();
    month[0]="January";
    month[1]="February";
    month[2]="March";
    month[3]="April";
    month[4]="May";
    month[5]="June";
    month[6]="July";
    month[7]="August";
    month[8]="September";
    month[9]="October";
    month[10]="November";
    month[11]="December";
    var temp = '';
   
    for (var i = 2006; i <= yr; i++)
    {
     
      temp += '<h3>'+i+'</h3><div><ul>';
        
      if(i<yr-1)
      {
         for (var j = 1; j <= 12; j++)
         {
             temp = temp + '<li><a href="somepage.html?year=2012&month='+j+'">'+ month[j-1]+'</a></li>';
         }
         temp = temp + '</ul></div>';
      }
      else
      {
         for (var j = 0; j <= mo; j++)
         {
             temp = temp + '<li><a href="somepage.html?year=2012&month='+j+'">'+ month[j-1]+'</a></li>';
         }
         temp = temp + '</ul></div>';
      }
    }
       
    $( "#accordion" ).append(temp);
    $( "#accordion" ).accordion();
});