Edit This Code:
See Result »
<!DOCTYPE html> <html> <head> <style> table, td { border: 1px solid black; } </style> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?73c27e26f610eb3c9f3feb0c75b03925"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </head> <body> <p>Click the button to create a caption element for the table.</p> <table id="myTable"> <tr> <td>cell 1</td> <td>cell 2</td> </tr> <tr> <td>cell 3</td> <td>cell 4</td> </tr> </table> <br> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var table = document.getElementById("myTable").createCaption(); table.innerHTML = "<b>My table caption</b>"; } </script> </body> </html>
Result: