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

Asked 1 years ago, Updated 1 years ago, 372 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.