//截取字符串
function cut(cutelement, cutlength) {
 
    
    var cutelement = $(cutelement);
    $.each(cutelement, function (i, item) {
        if (item.innerText.length > cutlength) {//循环判断cutelement中含有的字数
            item.innerText = item.innerText.substring(0, cutlength) + "...";//如果字数超过,则截取内容,拼接上“...”显示
        }

    })

}

调用eg(".content",30)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2022-12-23
  • 2021-09-21
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案