Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1218
  • Last Modified:

Changeing cellspacing & cellpadding useing javascript

How can I change cellspacing & cellpadding for a table useing javascript?

Something like:
document.getElementsByTagName('table')[0].cellspacing=0

thx
0
n01028345
Asked:
n01028345
  • 4
1 Solution
 
BatalfCommented:
Example:


<body>
    <table cellspacing="5" border="1" id="myTable">
        <tr>
            <td>
                <p>Test
            </td>
            <td>
                <p>Test
            </td>
        </tr>
    </table>

   
    <a href="#" onclick="javascript:document.getElementsByTagName('table')[0].cellSpacing='0'">Set</a>;
   
</body>
0
 
BatalfCommented:
And this is an example for cellpadding:

<body>
    <table cellpadding="5" border="1" id="myTable">
        <tr>
            <td>
                <p>Test
            </td>
            <td>
                <p>Test
            </td>
        </tr>
    </table>

   
    <a href="#" onclick="javascript:document.getElementsByTagName('table')[0].cellPadding='0'">Set</a>;
   
</body>
0
 
BatalfCommented:
The  id="myTable" is only for my testing. You could delete it.
0
 
n01028345Author Commented:
lol, thx

cellPadding&cellSpacing not cellspacing & cellpadding

funny :P

thx again alot :)
0
 
BatalfCommented:
Glad I could help!

Batalf
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now