I think I've seen this problem here once, but I could not find it at all or search the internet (I forgot what words to use in the search because I think I've dealt with it before but it gave me a total blank). >
I'm making a replace
of a text in a div
and inserting some words between the <b></b>
tags.
For example:
<div id="texto">
Qualquer texto aqui
</div>
I want the word "text" to be between <b></b>
(bold):
var texto_original = $("#texto").text();
$("#texto").text(texto_original.replace("texto","<b>texto</b>"));
It turns out that after replace
the text in div
looks like this:
Qualquer <b>texto</b> aqui
When it would look like this:
Any text here
See the example:
var texto_original = $("#texto").text();
$("#texto").text(texto_original.replace("texto","<b>texto</b>"));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="texto">
Qualquer texto aqui
</div>
That is, the tag is being treated as a string. If I am not mistaken there is a method that does this conversion, but I am not remembering at all. How do I resolve this?