Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

innerText seems to be adding "\n" sometimes

  • 2 replies
  • 1 has this problem
  • 29 views
  • Last reply by Col_Boogie

more options

have field: <td rowspan='2' id='OP' contenteditable="true">+</td> as long as I don't change it, OOP = document.getElementById("OP"); and OOP.innerText work fine however as soon as I change (edit) the value, OOP.innerText seems to be adding a "\n" after value This causes subsequent code to fail. If I change back to '+', error persists. Seems OOP.innerText.substr(0,1) is a workaround

have field: <td rowspan='2' id='OP' contenteditable="true">+</td> as long as I don't change it, OOP = document.getElementById("OP"); and OOP.innerText work fine however as soon as I change (edit) the value, OOP.innerText seems to be adding a "\n" after value This causes subsequent code to fail. If I change back to '+', error persists. Seems OOP.innerText.substr(0,1) is a workaround

Chosen solution

Maybe try textContent to avoid getting markup code to see if that works better. Initially Firefox only supported textContent and only supported innerText since Firefox 45 according to the MDN docs.

Read this answer in context 👍 1

All Replies (2)

more options

Chosen Solution

Maybe try textContent to avoid getting markup code to see if that works better. Initially Firefox only supported textContent and only supported innerText since Firefox 45 according to the MDN docs.

more options

Works from what I can tell. However, textContent needs to be fixed. It took me a while before I realized it was a browser error. An alert of the returned value was the subtle hint that found the error.