Set the table caption - Javascript CSS Style Property

Javascript examples for CSS Style Property:captionSide

Description

Set the table caption

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
    margin: 10px;
}
</style>/*from   www .j av a 2s  . com*/
</head>
<body>

<p>Click the button to get the position of the table caption.</p>

<button onclick="myFunction()">Test</button>

<table>
  <caption id="myCap" style="caption-side:bottom;">Table 1.1 Customers</caption>
  <tr>
    <th>Name</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Mary</td>
    <td>Mobile</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Tom</td>
    <td>Phone</td>
    <td>Sweden</td>
  </tr>
  <tr>
    <td>Edith</td>
    <td>Email</td>
    <td>Mexico</td>
  </tr>
</table>

<script>
function myFunction() {
    document.getElementById("myCap").style.captionSide = 'top';
}
</script>

</body>
</html>

Related Tutorials