function subString(str, len, hasDot) { var newLength = 0; var newStr = ""; var chineseRegex = /[^\x00-\xff]/g; var singleChar = ""; var strLength = str.replace(chineseRegex,"**").length; for(var i = 0;i < strLength;i++) { singleChar = str.charAt(i).toString(); if(singleChar.match(chineseRegex) != null) { newLength += 2; } else { newLength++; } if(newLength > len) { break; } newStr += singleChar; } if(hasDot && strLength > len) { newStr += "..."; } return newStr; } var questionListStr = ''; var myStr = ''; myStr = '性缘脑'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-08-08'; questionListStr = questionListStr + '浏览110次
  • '; myStr = '觉得自己社交困难'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-07-26'; questionListStr = questionListStr + '浏览48次
  • '; myStr = '人际交往'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-05-30'; questionListStr = questionListStr + '浏览81次
  • '; myStr = '看了年少日记久久不能释怀'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-05-07'; questionListStr = questionListStr + '浏览125次
  • '; myStr = '一个孩子的烦恼2'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-05-05'; questionListStr = questionListStr + '浏览70次
  • '; $('.zxzx ul').html(questionListStr);