In this example, we’ll learn How to Change The Border For a Table in Javascript.
HTML+JavaScript Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <!DOCTYPE html> <html> <head> <script> function changeBorder(id) { document.getElementById(id).style.border = "5px solid"; } </script> </head> <body> <table style="border:2px solid black" id="myTable"> <tr> <td>100</td> <td>200</td> </tr> <tr> <td>300</td> <td>400</td> </tr> </table> <p> <input type="button" onclick="changeBorder('myTable')" value="Change Border"> </p> </body> </html> |