html - Javascript Date Selection -
html - Javascript Date Selection -
i'm trying create day selection website , i'm having slight issue it. current issue stands @ this.
the if statement @ bottom doesn't seem searching , selecting info contains that? i'm not great javascript i'm not sure if that's how it?
overall want selects classes name show , searches contents of see if it's equal todays date, if colour green. i've tried thinking of different ways can can't seem head around , i've looked on here see if anyone's trying create simular date selections, not day selections.
javascript:
<script> function showdate() { var = new date(); var daynames = new array("sunday","monday","tuesday","wednesday","thursday","friday","saturday"); var shows = document.getelementsbyclassname('show'); var today = shows.innerhtml; var showelements = document.queryselectorall('show'); document.getelementbyid('datetoday').innerhtml = 'today is: ' + daynames[now.getday()]; if(today.contains(daynames[now.getday()])) { showelements.style.color = '#00e42d'; } } </script>
html:
<ul class="active"> <h1>active shows</h1> <li id="soa" class="show"><strong>sons of anarchy</strong> - tuesday</small></li> <li id="sp" class="show"><strong>southpark</strong> - wednesday</li> <li id="wlr" class="show"><strong>waterloo road</strong> - wednesday</li> <li id="twd" class="show"><strong>the walking dead</strong> - sunday</li> <li id="fg" class="show"><strong>family guy</strong> - sunday</li> </ul>
its easy utilize jquery
here js code :
<script> function showdate() { var = new date(); var daynames = new array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"); var today = daynames[now.getday()]; $('datetoday').html( 'today is: ' + today); $(".show:contains("+today+")").css("color","#00e42d"); } </script>
http://plnkr.co/edit/qjn6bkqcekhljudvic4l?p=preview
javascript html date
Comments
Post a Comment