Search

Rss Posts

Rss Comments

Login

 

How Can I change table cellPadding from JavaScript?

Jan 22

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script type=”text/javascript”>
function padding(){
document.getElementById(’myTable’).cellPadding=”20″
}
</script>
 
<table id=”myTable” border=”1″>
<tr>
<td>first</td>
<td>second</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
<form>
<input type=”button” onclick=”padding()” value=”Change Cellpadding to 20″>

1 Comment

Add your comment

  1. stephanie
    Jul 02 at 18:06

    Just use:
    var tbl = document.getElementById(‘myTable’);
    tbl.cellpadding = ’20px’;
    tbl.cellspacing = ’20px’;

    worked for me anyway.

Post a comment

 
Get Adobe Flash playerPlugin by wpburn.com wordpress themes
32 queries. 0.307 seconds.