javascript - display or read colspan value -
i created table contain colspan , rowspan. or read these colspan , rowspan value. i'm doing because want use xml generation. need value. play around code test:
<!doctype html> <html> <head> <script> function displayresult() { document.getelementbyid("myheader1").colspan="2"; } function displaycolspan() { var te; document.getelementbyid("myheader1").colspan=te; alert(te); } </script> </head> <body> <table border="1"> <tr> <th id="myheader1">month</th> <th id="myheader2">savings</th> </tr> <tr> <td>january</td> <td>$100.00</td> </tr> <tr> <td>february</td> <td>$10.00</td> </tr> <tr> <td>march</td> <td>$80.00</td> </tr> </table> <br> <button type="button" onclick="displayresult()">change colspan first cell</button> <button type="button" onclick="displaycolspan()">test</button> </body> </html>
could me? thanks!
there's bit of confusion code.
this:
document.getelementbyid("myheader1").colspan=te;
changes colspan value of myheader1 var te
, undefined. instead should do:
te = document.getelementbyid("myheader1").colspan
now te
colspan value of myheader1.
if want value, 'month':
te = document.getelementbyid("myheader1").innerhtml
now te has value of 'month'!
hope helps!
Comments
Post a Comment