javascript - Change class on date -



javascript - Change class on date -

absolute scripting noob here, i've got problem that's been bugging me 3 day's straight now.

i'm trying create script work advent calendar.

so: 01 dec 2014 door 1 opens, 02 dec 2014 door 2 opens (door 1 stay's open) ect...

now might have gotten totally wrong i've got @ moment :

class="snippet-code-js lang-js prettyprint-override">$(function(){ // event handler close current popup when clicking on widgets "close_when_clicked" css class $('body').on('click', '.boxy-content.close_when_clicked', function(e){ if (!$(e.target).is('a')){ e.preventdefault(); var boxy = boxy.get(this); boxy.hideandunload(); } }); var i, current_day, day, startdate; var $cal = $('.calendar'), $prizes = $('.prizes > *'), $lockedmsg = $('.locked_msg'); var = new date(), totaldays = $prizes.length; // alter # of days displayed $('span.total_days').text(totaldays); // check date override var timenow_re = window.location.href.match(/timenow=([\w%]+)/); if (timenow_re) { var parsed = date.parse(decodeuricomponent(timenow_re[1])); if (parsed) { = new date(parsed); } } var nowdate = new date(now.getfullyear(), now.getmonth(), now.getdate()); startdate = new date(startyear, startmonth - 1, startday); secsperday = 1000 * 60 * 60 * 24; currentday = math.floor( (nowdate - startdate + 1) / secsperday ) + 1; // setup links each day (i=1; i<=totaldays; i++) { $cal.append('<a class="day' + ((i > currentday) ? " locked" : " unlocked") + '" href="#" data-day="' + + '">' + + '</a>'); } // unlocked click handler $('.calendar .unlocked').attr('target', '').click(function(event) { var day = $(event.target).data('day'); var prize = $prizes.get(day-1); if (prize) { var config = sst.widget_config(prize); sst.widget_popup(config, this); } else { ss_alert('there no popup configured day ' + day + '. add together rich text, image, promotion or custom form widget configured display popup, add together calendar settings.'); } event.preventdefault(); }); // locked click handler $('.calendar .locked').attr('target', '').click(function(event) { var config = sst.widget_config($lockedmsg.get(0)); sst.widget_popup(config, this); event.preventdefault(); }); }); </script> class="snippet-code-html lang-html prettyprint-override"> <a class="day unlocked" href="#" data-day="1" target="">1</a> <a class="day unlocked" href="#" data-day="2" target="">2</a> <a class="day unlocked" href="#" data-day="3" target="">3</a> <a class="day unlocked" href="#" data-day="4" target="">4</a> <a class="day unlocked" href="#" data-day="5" target="">5</a> <a class="day unlocked" href="#" data-day="6" target="">6</a> <a class="day unlocked" href="#" data-day="7" target="">7</a> <a class="day unlocked" href="#" data-day="8" target="">8</a> <a class="day unlocked" href="#" data-day="9" target="">9</a> <a class="day unlocked" href="#" data-day="10" target="">10</a> <a class="day unlocked" href="#" data-day="11" target="">11</a> <a class="day unlocked" href="#" data-day="12" target="">12</a> <a class="day unlocked" href="#" data-day="13" target="">13</a> <a class="day unlocked" href="#" data-day="14" target="">14</a> <a class="day unlocked" href="#" data-day="15" target="">15</a> <a class="day unlocked" href="#" data-day="16" target="">16</a> <a class="day unlocked" href="#" data-day="17" target="">17</a> <a class="day unlocked" href="#" data-day="18" target="">18</a> <a class="day locked" href="#" data-day="19" target="">19</a> <a class="day locked" href="#" data-day="20" target="">20</a> <a class="day locked" href="#" data-day="21" target="">21</a> <a class="day locked" href="#" data-day="22" target="">22</a> <a class="day locked" href="#" data-day="23" target="">23</a> <a class="day locked" href="#" data-day="24" target="">24</a> </div>

the class of html should alter "day locked" when date before 1st of december. on 1st code should alter class of date-dat="1" "day unlocked' , on.

could give me few pointers how can alter class on specific date? ( , not 1 once, 1 day @ time? )

thanks in advance !!

edit: i've tried php, but

<a class="day <?php if(date('z') == 304 ) echo 'unlocked' ?> href="#" data-day="1" target="" ">1</a>

didnt seem work....

javascript class date

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -