Place value in Paragrafo without javascript interpreting HTML tag

Asked

Viewed 36 times

-1

I have a paragraph<p id='meuParagrafo' >paragra</p> and in Javascript I want to do this document.querySelector("#meuParagrafo").innerHTML = "<b>Bem legal</b>"; the only problem is that the tag <b> left my code in bold, and I don’t want it, I want the paragraph to appear the tag <b>Bem legal</b> without the bold

NOTE: I’m doing a chat, so I can’t leave the interpretation of Tags

1 answer

0

I searched the internet, I thought that solved my problem

SUA_STRING.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.