How to change table border with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>

<head>  
</head>
  
<body>

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



<script>        

function change_table_border() 
{
     document.getElementById("table-id").style.border = "4px solid red";
}

/*
run:
  
on button click table border will change to "4px solid red"
    
*/

</script>
<button onclick="change_table_border()">change table border</button>

</body>
</html>

 



answered Aug 16, 2015 by avibootz
edited Aug 17, 2015 by avibootz
...