1

I want to replace a tag using .innerHTML.

It looks like this:

var foo = document.getElementsByTagName("Foo");
for(var i = 0; i < foo.length; i++) {
   foo[i].innerHTML = "<Bar>Lorem ipsum</Bar>";
}

However, since .innetHTML returns case-insensitive on Firefox and it's not consistant across web browers. I got

<bar>lorm ipsum</bar>

What should I do to get case-sensitive return? (Without using jQuery or too-complex code).

I have searched and found this, and this, but those are 9 and 5 years old and not really answer what I need. So I think it'd be ok to ask this question again.

Thanks in advance!

Thammarith
  • 662
  • 5
  • 19
  • is not valid Html. You cannot put it inside. Why do you want a capital on your tag? – ChrisR Aug 12 '18 at 14:48
  • @ChrisR I just want to experiment with custom tags. I use custom tags for ease of style in CSS. (I know it sounds silly, but it's just a random thing to experiment.) – Thammarith Aug 12 '18 at 14:50
  • HTML tag names are simply not case-sensitive, so it doesn't matter. `` and `` and `` mean exactly the same thing. – Pointy Aug 12 '18 at 14:59
  • 1
    Browsers are/were inconsistent with how they handle the case of unknown tag names, [fun read](https://johnresig.com/blog/nodename-case-sensitivity/). Don’t rely on this technique. – James Aug 12 '18 at 15:04

0 Answers0