利用JavaScript截取HTML而不会丢失标记 - Cutter.js

12年前
Cutter.js is a JavaScript class that allows us to accomplish this on the client-side without losing markup.

Cutter.js

The class cuts the content to the number of requested words and if needed puts a link to open the full content again and, if wanted, places a link to open the full content.

It is a standalone + lightweight resource (1.5kb gzipped) and works cross-browser.