生成表头名称作为当前月份名称 [英] Generate table header name as current month name
本文介绍了生成表头名称作为当前月份名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在html中,如何将表列名称生成为当月的名称?例如。
本月表标题应该是:
StudentName March
下个月,
StudentName April
等等。 。
我的尝试:
学生姓名 | 本月 | Rabiya | 123 |
---|
Hi,
In html, how do I generate table column name as current month's name? For example.
For this month table header should like :
StudentName March
Next month,
StudentName April
and so on..
What I have tried:
Student Name | Current Month |
---|---|
Rabiya | 123 |
推荐答案
试试以下代码:
Try with below code:
<html>
<body>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<th>
StudentName
</th>
<th id="monthName">
</th>
</tr>
<tr>
<td>
Manas
</td>
<td>
1000
</td>
</tr>
</table>
<script>
var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var d = new Date();
var n = month[d.getMonth()];
document.getElementById("monthName").innerHTML = n;
</script>
</body>
</html>
这篇关于生成表头名称作为当前月份名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文