Get the text without HTML tags by javascript
Topics related to client-side programming language.
Post questions and answers about JavaScript, Ajax, or jQuery codes and scripts.
-
Marius
- Posts:107
Get the text without HTML tags by javascript
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:
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>
Admin
Posts:805
You can use this:
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_elm = document.getElementById('d_id');
// innerText for IE, textContent for other browsers
var get_text = get_elm.innerText || get_elm.textContent;
alert(get_text);
</script>
Or, if you use jQuery:
Similar Topics
- Speech to text without https
General Forum
First post
Pleasant Coursesweb,
Is their anything posible without https for speech to text fill-in ?
Or must I turn my SSL document on the XAMPP-server ?
Last post
Hello,
I don't know about speech to text fill-in.
Anyway, I want to inform you that this forum will be closed for register or posting.
Any...
- Display message to every minute in Javascript
JavaScript - jQuery - Ajax
First post
Hello,
On eatch minute from the current hour I wanna have an message
I can not find out how to complete
I hope to get something like this (code...
Last post
If you only want to display a message to every minute, just use the setInterval() function. It calls a function repeatedly, over and over again, at...
- Hour and Minutes togheter in Javascript
JavaScript - jQuery - Ajax
First post
Dear Coursesweb I can not find out how to add the hours + minutes togheter.
<SCRIPT LANGUAGE= JavaScript >
day = new Date()
hr =...
Last post
See and use the following example:
<script>
var day = new Date();
let hr = day.getHours();
let mn = day.getMinutes();
let se =...