Click to See Complete Forum and Search --> : onclick of a button should change the table border color??
shanuragu
09-22-2003, 08:21 AM
HI
Initially the table border color will be black. Click of a button should change the table border color to red. how can I do it??
shara
Like this:
<table id="mytable" style="border: 1px solid black;">
<tr>
<td>test</td>
</tr>
</table>
<button type="button" onclick="document.getElementById('mytable').style.borderColor='red';">Change Border Color</button>
shanuragu
09-22-2003, 10:48 PM
Thanks Pyro.
Any other method?? like using a javascript function etc???
shara
That is a JavaScript function, but if you want it to run an actual function in the <head> try this:
<script type="text/javascript">
function setColor() {
document.getElementById("mytable").style.borderColor="red";
}
</script>
</head>
<body>
<table id="mytable" style="border: 1px solid black;">
<tr>
<td>test</td>
</tr>
</table>
<button type="button" onclick="setColor();">Change Border Color</button>