要?jiǎng)?chuàng)建表格標(biāo)題,請(qǐng)使用 DOM createCaption() 方法。
示例
您可以嘗試運(yùn)行以下命令代碼來(lái)學(xué)習(xí)如何創(chuàng)建表格標(biāo)題 –
現(xiàn)場(chǎng)演示
<!DOCTYPE html>
<html>
<head>
<script>
function captionFunc(x) {
document.getElementById(x).createCaption().innerHTML = "Demo Caption";
}
</script>
</head>
<body>
<table style="border:2px solid black" id="newtable">
<tr>
<td>One</td>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
<tr>
<td>Five</td>
<td>Six</td>
</tr>
</table>
<p>
<input type="button" onclick="captionFunc('newtable')" value="Display Table Caption">
</p>
</body>
</html>
登錄后復(fù)制
以上就是如何使用JavaScript DOM創(chuàng)建表格標(biāo)題?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!






