Когда я нажимаю кнопку Test , он выводит значения innerhtml и innertext внутри. >
Код: Выделить всё
innerHTMLтеги в конце)
Код: Выделить всё
This[/i] is one line
This is [u]another[/u] line
< /code>
innerTextКод: Выделить всё
This is one line
This is another line
< /code>
What I want to achieve: be able to "trim" the innerHTML value (i.e., remove blank lines) while keeping the formatting. This is simple to do with the innerText value (just something like document.getElementById("id").innerText.trim()Код: Выделить всё
function test() {
var html = document.getElementById("inputBox").innerHTML;
var text = document.getElementById("inputBox").innerText;
console.log(`html:\n${html}`);
console.log(`text:\n${text}`);
}< /code>
table {
width: 100%;
}
td#inputBox {
height: 100px;
border: 1px solid #020202;
}< /code>
TestПодробнее здесь: https://stackoverflow.com/questions/794 ... le-element
Мобильная версия