js或者cs代码拼接html

一:使用到的jQuery 文档操作方法

html() 设置或返回匹配的元素集合中的 HTML 内容。

append() 向匹配元素集合中的每个元素结尾插入由参数指定的内容。

empty() 删除匹配的元素集合中所有的子节点。

二:注意的事项

引号的非转义,使用“”

$("#table_threeDay").append('<tr class="' + dataClass + '" >'
        + '<th id="' + handId + '" rowspan="2"><img src="/Pc/Images/Default/WorkPage/' + img + '"/> </th>'
        + '<th id="' + dataId + '" class="th_day" rowspan="2">' + txt
        + '</th>'
        + '<td>'
        + '毛利润'
        + '</td>'
        + '<td class="td_value">'
        + '¥' + doubleTwo(getPropertyValue(data, thisDay, ProfitType))
        + '</td>'
        + '</tr>'
        + '<tr>'
        + '<td>'
        + '利润率'
        + '</td>'
        + '<td class="td_value">'
        + doubleTwo(getPropertyValue(data, thisDay, RateType)) + ' %'
        + '</td>'
        + '</tr>'
        + enter);

还有我个人的习惯,将“+”和“‘”放到最前面,而且对齐,是不是看起来很清楚呢,是不是不容易出现某行少个单引号的情况呢

原文地址:https://www.cnblogs.com/hongmaju/p/5115641.html