The above code changes the content of an element on the page, I have tried it in FireFox and it behaves perfectly, however, try it in Internet Explorer and it falls over. Anyone have any ideas how to get around this in IE? I'm slowly going crazy!!! Thanks
<html> <body> <table> <tr> <td id="1">Before</td> </tr> <tr> <td> <a href="#" onClick="document.getElementById('1').innerHTML='After'; return false;">Change</a> </td> </tr> </table> </body> </html> Code (markup):
I'm thinking since he want's to change the innerHTML of a <tr> instead of a <td>, he must have a reason. He must have thought it's possible to use <td> instead of <tr> ....
innerHTML for TR can too be done. <html> <body> <table> <tr id="1"> <td>Before</td> </tr> <tr> <td> <a href="#" onClick="document.getElementById('1').innerHTML='<td>After</td>'; return false;">Change</a> </td> </tr> </table> </body> </html> Code (markup):
The reason I've changed id to td because tr id won't work in IE. So the code Felu posted is not working in IE....
Thanks for all the responses folks, I have figured it out. You can see the final 'digg spy' like product at http://www.in4matrix.co.uk/spy Thanks Sanjay