How to set table caption with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>

<head>  
</head>
  
<body>

<table id="table-id" style="border:1px solid coral">
<tr><td>abc</td><td>def</td></tr>
<tr><td>ghi</td><td>jkl</td></tr>
</table>


<script>        

function createTableCaption(id) 
{
    document.getElementById(id).createCaption().innerHTML = "Your table caption";
}

/*
run:
  
On button click table caption will set to: "Your table caption"
    
*/

</script>

<button onclick="createTableCaption('table-id')">Create Table Caption</button>

</body>
</html>

 



answered Aug 19, 2015 by avibootz

Related questions

1 answer 179 views
179 views asked Dec 13, 2018 by avibootz
1 answer 207 views
1 answer 190 views
...