处理富文本,富文本转字符串(删除&apos"等)
function myTooltip(value) {
let length = 10, target = 'open';
var _length = $.common.isEmpty(length) ? 20 : length;
var _text = "";
var _value = $.common.nullToStr(value);
var _target = $.common.isEmpty(target) ? 'copy' : target;
if (_value.length > _length) {
// _text = _value.substr(0, _length) + "内容";
_value = _value.replace(/\'/g,"'");
_value = _value.replace(/\"/g,""");
// 去除标签
let tipShow = _value.replace(/<\/?.+?>/g,"");
tipShow = tipShow.replace(/\s/g,"");
tipShow = tipShow.substring(0, 200)+'......';
var actions = [];
actions.push($.common.sprintf('<input style="opacity: 0;position: absolute;width:5px;z-index:-1" type="text" value="%s"/>', _value));
actions.push($.common.sprintf('<a href="###" class="tooltip-show" data-toggle="tooltip" data-target="%s" title="%s">%s</a>', _target, tipShow, '点击查看详情'));
return actions.join('');
} else {
_text = _value;
return _text;
}
}
非原创,转载分享