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
<buttononClick="myFunc()">click</button><scripttype="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
<tableborder="1"><tr><tdclass="tabletd"> text one </td><br><tdclass="tabletd"id="tdSecond"> this is next td</td></tr></table><buttononclick="myFunc()">click</button>
Post a Comment for "Td Without Parent Table Tag"