Reputation: 45
I have a div, which has the css to truncate the text for certain width. The text gets truncated with ellipsis. However the inner text is the same. For the testing purpose I would want to read the truncated ellipsis text. Can I get the truncated ellipsis text with js?
@media (max-width: 1129px) {
#mydiv {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100px;
display: inline-block;
}
}
Upvotes: 0
Views: 3835
Reputation: 146
There's no easy way to do this, you'd have to do it manually with JavaScript by:
It's also been discussed here Get clamped (with ellipsis) textContent from textNode
Upvotes: 1