Търсене в помощните статии

Избягвайте измамите при поддръжката. Никога няма да ви помолим да се обадите или изпратите SMS на телефонен номер или да споделите лична информация. Моля, докладвайте подозрителна активност на "Докладване за злоупотреба".

Learn More

innerText seems to be adding "\n" sometimes

  • 2 отговора
  • 1 има този проблем
  • 28 изгледи
  • Последен отговор от 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

Избрано решение

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.

Прочетете този отговор в контекста 👍 1

Всички отговори (2)

more options

Избрано решение

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.