前端字符串拼接

  • Post author:
  • Post category:其他


1、描述:使用jquery的each函数

var htmlStr = “”;

$.each(data.activityList, function (index, obj) {

htmlStr += “<tr class=\”active\”>”;

htmlStr += “<td><input type=\”checkbox\” value=\”” + obj.id + “\”/></td>”;

htmlStr += “<td><a style=\”text-decoration: none; cursor: pointer;\” οnclick=\”window.location.href=’detail.html’;\”>” + obj.name + “</a></td>”;

htmlStr += “<td>” + obj.owner + “</td>”;

htmlStr += “<td>” + obj.startDate + “</td>”;

htmlStr += “<td>” + obj.endDate + “</td>”;

htmlStr += “</tr>”;

});

$(“#tBody”).html(htmlStr);



版权声明:本文为weixin_65805023原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。