Is there a way to replace all intstances of a string but only when it is contained in html tags shown to the user with javascript?

Viewed 38

For example, if i wanted to replace "mystring" with "myotherstring" in

<!DOCTYPE html>
<html>
<body>
<h1 id="mystring">mystring</h1>
<p>mystring</p>
<script>mystring javascript blah</script>
</body>
</html>

how could i only replace it in the <h1> and <p> tags with javascript, or can i do it without js?

1 Answers
Related