CSharpBeginner CSharpBeginner - 5 months ago 10
HTML Question

Get div innetText by Javascript

i'm new at Javascript.

I have the following table:


<table id='master_tbl'>
<tbody>
<tr id="master_hr'>
<td class="myclass">
<table>
<tbody>
<tr>
<td>
<span class="myclass2>
<div class="myclass3">MyText</div>
</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>


How can i get the "MyText" string?

Note: I cannot add any id attribute to the html text.

Answer

var m = document.getElementById("master_hr").getElementsByClassName("myclass3")[0].innerHTML;