初学js,求指点

484518 2016-11-10 07:35:38

mainContent.find(".catList a").button();
mainContent.find(".grid .title").css({ });
mainContent.find(".grid tr").css("color", "#333333;");
mainContent.find(".grid .role").each(function () {
var cTexts = $(this).text().split('_');
switch (cTexts[0]) {
case "0":
cTexts[0] = '系统';
$(this).parent().find(".sname").text('系统通知');
$(this).parent().parent().find(".attLinks").remove();
break;
case "1":
cTexts[0] = '我的发言';
break;
case "2":
cTexts[0] = '客服人员';
if (departments['dpname_' + cTexts[1]] != undefined) cTexts[0] = departments['dpname_' + cTexts[1]] + '';
$(this).parent().parent().find(".attLinks").remove();
break;
}
$(this).text('' + cTexts[0] + '');
});


上面的js代码,我想给case {0,1,2}这三个都加不同的html代码进去,求怎么加

像这种一样,直接加在文字里面

switch (rmsg[1]) {
case "The title or content can not be empty": msg = '<div class="zidingyi"><img src="../../img.jpg">标题或内容不能为空!</div>'; break;
default: msg = rmsg[1]; break;
}
...全文
59 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
484518 2016-11-10
  • 打赏
  • 举报
回复
引用 1 楼 superwfei 的回复:
$(this).text('' + cTexts[0] + ''); $(this).html('<span>' + cTexts[0] + '</span>');
又看了下你给的,现在知道怎么做了,非常感谢
484518 2016-11-10
  • 打赏
  • 举报
回复
引用 1 楼 superwfei 的回复:
$(this).text('' + cTexts[0] + ''); $(this).html('<span>' + cTexts[0] + '</span>');
这样的话,0 1 2 三个都加上了一样的样式 我想三个分开, 每个都加不同的样式
文盲老顾 2016-11-10
  • 打赏
  • 举报
回复
$(this).text('' + cTexts[0] + ''); $(this).html('<span>' + cTexts[0] + '</span>');
木头海上漂 2016-11-10
  • 打赏
  • 举报
回复
数组或者对象循环匹配

87,902

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧