I want to change the string between specific tags in JavaScript.

Asked 2 years ago, Updated 2 years ago, 380 views

What should I do if I want to change the string in an H3 tag in JavaScript?

<h3id="test><font color="red">I want to change this character.</font></h3>

javascript

2022-09-30 21:58

1 Answers

 document.getElementById("test").innerHTML="<font color='red'>newtext</font>";

If you also add an ID to the font label,

<h3id="test">fontid="test2" color="red">I want to change the character here.</font></h3>

Below:

 document.getElementById("test2").textContent="newtext";


2022-09-30 21:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.