js controls the number of characters displayed in the text, beyond the display ellipsis

In css, we said to use css to control the text to display a few lines, beyond using ellipsis, but this method is to completely occupy a whole line, but there are UI designers who don't do this, do you really want to hit him, ha Haha, I always scold designers like this when I don’t know how. I like to do something special for so long. After scolding, let’s work hard. Their peculiar ideas will only make us progress in the end! Back to the topic, look at the result picture and speak.

Note: It is necessary to judge how long it takes to display the ellipsis. If no judgment is made, there will be ellipses even if the number of characters is not reached.

Supplement: The substring() method is used to extract characters between two specified subscripts in a string.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324937382&siteId=291194637