Skip to content Skip to sidebar Skip to footer

Td Without Parent Table Tag

HTML: text one
this is next td

Solution 2:

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.


Solution 3:

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"