Как я могу получить зажатый текст с узла в javascript? Смотрите ниже код:Получить зажим (с эллипсисом) textContent from textNode
console.log(document.getElementById("text1").textContent);
// prints "This is a long text"
console.log(document.getElementById("text2").textContent);
// prints "This is a long text as well"
// expected "This is a long text a..."
.longtext {
width: 140px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<div id="text1">This is a long text</div>
<div class="longtext" id="text2">This is a long text as well</div>
Я хочу, чтобы получить ожидаемый "This is a long text a..."
от элемента с идентификатором text2
.