I can remove all html tags from the text but I cannot remove just the structure in span tags with data-word inside ...
function strip(html)
{
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || "";
}
Original is:
I <span data-word="word1" class="synonyms" title="word2">word3</span> <b>word4<b>.
The result should be:
I word3 <b>word4</b>.
With the script from above the result I get is:I word3 word4. So the remaining html is not preserved.
It is code from Strip HTML from Text JavaScript.
</b>not<b>.spantags that have adata-wordattribute (and replace them by their content)?