0

I am trying to get innerHTML of contenteditable field, and relying on that decide save it or not.

I have markup like this

<div class="users-overlay" contenteditable></div>

so when I am using document.querySelector('.users-overlay').innerHTML it returns <br>. This behaviour appears only on IE/Edge. I need to get rid of this somehow. Because even when I write document.querySelector('.users-overlay').innerHTML = '' it is still here. Thanks in advance.

Word Rearranger
  • 1,306
  • 1
  • 16
  • 25
Kraken
  • 1,905
  • 12
  • 22
  • I can't reproduce your issue on IE or Edge. My guess is something else not mentioned in your question is adding the tag. – Word Rearranger Nov 20 '19 at 16:01
  • Why don't you just strip the first "
    " from the content if there is one at the begining of it?
    – LordNeo Nov 20 '19 at 16:01
  • i can strip it, but i want to realize why it appears. – Kraken Nov 20 '19 at 16:10
  • You can't rely on `innerHTML` anyway, the places of the attributes are changing from time to time in IE. – Teemu Nov 20 '19 at 16:13
  • Forgot to mention, i checked on other sites, ye it is not present. May be because i am using Angular. – Kraken Nov 20 '19 at 16:14
  • @Edit I verified the OPs issue. If you grab innerHTML of an empty contentEditable div in IE it returns `
    `. I looked into it a bit and found [this](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6492250/) edge bug report that sounds similiar.
    – Marie Nov 20 '19 at 20:15

0 Answers0