I have the following HTML:
<html>
<body>
<b /> <br>
Lets say it again: <b /> <br>
</body>
<script>
// this runs after document has already been loaded
if (document.getElementsByTagName('b').length > 0) {
Array.from(document.getElementsByTagName('b')).forEach((ele) => {
ele.innerHTML = "hello world!";
});
}
<script>
</html>
The result is that only the first <b />
gets its innerHTML modified. and NOTHING bellow this gets shown. Inspect shows no further HTML bellow the first <b />
However, if I replace <b />
with <b></b>
then everything works just fine.
Any idea why or how it could be fixed? I am using a tag to place a variable and I'd rather it be short as I have quite a few of them.
Thanks!