Home >Web Front-end >Front-end Q&A >How to implement excess ellipses in jquery
Jquery method to implement excess ellipses: 1. Create a js sample file; 2. Use the "$(".ftlt_lt_wzne").each(function() {...}" method to achieve the merging of limited text Just use an ellipsis when exceeding.
The operating environment of this tutorial: windows7 system, jquery3.2.1 version, Dell G3 computer.
How does jquery realize the ellipsis that exceeds the limit?
jquery uses ellipses to limit the text beyond the limit
We all know that using css3 can display ellipses beyond one line, but using css3 for multiple lines is very troublesome. We also need to consider compatibility. Today we use jquery to determine the number of words to limit the occurrence of ellipses
$(".ftlt_lt_wzne").each(function() { var maxwidth =36;//显示多少字符 if ($(this).text().length > maxwidth) { $(this).text($(this).text().substring(0, maxwidth)); $(this).html($(this).html() + '...'); } });
Recommended study: "jquery video tutorial"
The above is the detailed content of How to implement excess ellipses in jquery. For more information, please follow other related articles on the PHP Chinese website!