Get the text without HTML tags by javascript
Posted: 18 Nov 2014, 09:43
Hi,
I have a Div with some content and other html tags inside.
How can I get all the text content of this Div, without the html tags?
I ussed innerHTML property, but gets the tags too.
This is what i tried:
I have a Div with some content and other html tags inside.
How can I get all the text content of this Div, without the html tags?
I ussed innerHTML property, but gets the tags too.
This is what i tried:
Code: Select all
<div id="d_id">
Some content ...
<p>Other html element.</p>
<span>Text in Another html tag</span>
</div>
<script>
var get_text = document.getElementById('d_id').innerHTML;
alert(get_text);
</script>