Solution 1 :

You have to find &gt; (greater than) in Regex and replace with <.

Read more here

<p id="demo">this > and this > symbol should be replaced.</p>

<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
  var str = document.getElementById("demo").innerHTML; 
  var res = str.replace(/&gt;/g, "%3E");
  document.getElementById("demo").innerHTML = res;
}
</script>

Problem :

I need to change > to %3E .., if the > symbol is changed by another symbol, everything works fine.
How can I correct this?

<p id="demo">this > and this > symbol should be replaced.</p>

<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
  var str = document.getElementById("demo").innerHTML; 
  var res = str.replace(/>/g, "%3E");
  document.getElementById("demo").innerHTML = res;
}

Comments

Comment posted by tao

innerHtml

Comment posted by Ry-

What happens if there’s other HTML in the

Comment posted by maja

if i change to test: (/> / g, “% 3E”) in (/> / g, “RED”) still does not work. He just doesn’t want to change me < or >

Comment posted by Ritesh Khandekar

@maja Have you seen my updated answer?

Comment posted by maja

I need replace > to %3E

Comment posted by maja

Thanks for the reply Ritesh Khandekar. I think your answer is definitely correct, but if I insert it into my notepad ++ where I code it doesn’t work .. I’m wrong somewhere. I write after the test. I don’t know why so many minuses on the question. 🙁

Comment posted by tao

@maja, why are you expecting any DOM method to work inside notepad++? notepad++ is a text editor, not a browser. There is no DOM in notepad++ and therefore you shouldn’t expect web javascript scripts to magically work just because the contents of your file happens to be the source of a web page. However, if you open that file in a browser, the script will work correctly.

Comment posted by Ritesh Khandekar

@maja I think you should take care of everything in Regex, even a space. And i think community want you to edit your question and be specific on one problem.

By