<html>
<script type="text/javascript" src="jquery.js"></script>
<body>
<table>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</table>
<script type="text/javascript">
var dayOfWeek = ["Sun","Mon","Tue","Wed","Thurs","Frid","Sat",];
$(document).ready(
function () {
var today = new Date();
$('th').each(function(index){
if(index !=0){
$(this).text(dayOfWeek[today.getDay()]);
today.setDate(today.getDate()+1);
}
});
// body...
}
);
</script>
</body>
</html>
Jquery .each() function
Chung Tran | 11 December 2012 | jquery |
Download jquery library and try this code :