I’m trying to create a calender application using jquery.
I’m using a table that has a col for each date.
<td>17</td>
I want to add a class to the date that is today. Not very good with jquery though. How can I fix this?
<script type="text/javascript">
$(document).ready(function(){
$('td').load( function(){
var today = new Date();
if($(this).innerText()== today.getDay(){
this.addClass("today")
}
})
});
</script>
I don’t think you need the
.load().$(document).ready()should do what you need.You’ll need to parse the date, too. Try this:
Edited after I saw the data that is actually in the
<td>s in the OP’s post.