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 + '2025-01-15'; questionListStr = questionListStr + '浏览45次
  • '; myStr = '焦虑'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-12-15'; questionListStr = questionListStr + '浏览96次
  • '; myStr = '研究生'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-12-13'; questionListStr = questionListStr + '浏览68次
  • '; myStr = '怎么才能还清欠父母的债(6)'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-12-01'; questionListStr = questionListStr + '浏览104次
  • '; myStr = '我觉得我总在比较(后)'; questionListStr = questionListStr + '
  • '; questionListStr = questionListStr + '' + subString(myStr, 40, true) + ''; questionListStr = questionListStr + '2024-11-11'; questionListStr = questionListStr + '浏览119次
  • '; $('.zxzx ul').html(questionListStr);