If you inspect the element in chrome you will notice the code has changed to the following:
<body>
text one <br>
this is next td
<button onClick="myFunc()">click</button>
<script type="text/javascript">//<![CDATA[
function myFunc() {
var second=document.getElementById('tdSecond').innerHTML;
alert(second);
//var second2=document.getElementsByTagName('td')[1].innerHTML;
//alert(second2);
}
//]]>
</script>
</body>
The td elements have been stripped by the browser as they are not valid.
Try this.There are html problems. try this html
<table border="1">
<tr>
<td class="tabletd"> text one </td><br>
<td class="tabletd" id="tdSecond"> this is next td</td>
</tr>
</table>
<button onclick="myFunc()">click</button>
Post a Comment for "Td Without Parent Table Tag"