I need to get the content a cell in a one-column table. When I use .innerText I lose the last empty character. Here is my code :

When I want to display my object (raw) :

console.log(myRow);

I get (with last character of cell empty) :

<tr class="t-state-selected">
    <td>Some data </td>
</tr>

But when I want the innetText :

console.log("'" + myRow.innerText + "'");

I get :

'Some data'

Why am I losing this last empty space ? How can I get all the data?

有帮助吗?

解决方案

Try using .textContent instead of .innerText which trims it.

Or if you need <IE9 support you could perhaps use .innerHTML

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top