首页 > 其他 > 详细

字符串除了第一位和最后一位中间用*替换

时间:2017-05-23 12:55:05      阅读:400      评论:0      收藏:0      [点我收藏+]

$(".user-name").each(function(){
var userName = $(this).html().trim();
var _name = "";
var nameLength = userName.length;
if (nameLength > 2) {
var nameLength = nameLength - 2;
while (nameLength > 0) {
_name += "*";
nameLength--;
}
userName = userName.substr(0, 1) + _name + userName.substr(userName.length - 1, userName.length);
$(this).html(userName);
}
})

字符串除了第一位和最后一位中间用*替换

原文:http://www.cnblogs.com/qhhw/p/6893373.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!