
innerText seems to be adding "\n" sometimes
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.
- https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText
All Replies (2)
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.
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.