$ (function () {
Control one-line semi-hide
(function ($) {
$.fn.displaypart = function (opts) {
$ (this). each (function () {
Displaypart ($ (this), opts);
});
}
function Displaypart ($el, opts) {
var defaults = {
DISPLAYLENGTH:50//Specific number of words you want to display
}
This. Settings = $.extend (defaults, opts);
if (this. Settings.displaylength = = Defaults.displaylength && $el. Data ("Textcount")) {
This. Settings.displaylength = $el. Data ("Textcount");
}
var displaylength = this. Settings.displaylength;
var text = $el. Text ();
if (!text) return "";
var result = "";
var count = 0;
for (var i = 0; i < displaylength; i++) {
var _char = Text.charat (i);
if (count >= displaylength) break;
if (/[^x00-xff]/.test (_char)) count++; Double-byte characters,//[u4e00-u9fa5] Chinese
result + = _char;
count++;
}
if (Result.length < text.length) {
Result + = "...";
}
$el. Text (result);
}
}) (JQuery);
$ ("P"). Displaypart ();
Control one-line semi-hide
})
A half-line of the ellipsis is displayed in the JS package. (Free word control)