JS实现为表格动态添加标题的方法
本文实例讲述了JS实现为表格动态添加标题的方法。分享给大家供大家参考。具体如下:
JS中的表格对象带有一个createCaption方法用于为表格创建标题caption
<!DOCTYPE html>
<html>
<head>
<script>
function createCaption()
{
var x=document.getElementById('myTable').createCaption();
x.innerHTML="My table caption";
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
</table>
<br>
<input type="button" onclick="createCaption()"
value="Create caption">
</body>
</html>希望本文所述对大家的javascript程序设计有所帮助。
相关推荐
移动开发与培训 2020-08-16
ReunionIsland 2020-08-16
Zhongmeishijue 2020-09-10
runner 2020-09-01
梦的天空 2020-08-25
IdeaElements 2020-08-19
luvhl 2020-08-17
lyqdanang 2020-08-16
NARUTOLUOLUO 2020-08-03
MyNameIsXiaoLai 2020-07-08
星辰的笔记 2020-07-04
csstpeixun 2020-06-28
letheashura 2020-06-26
liaoxuewu 2020-06-26
OldBowl 2020-06-26
北京老苏 2020-06-25
Luffyying 2020-06-25