小结:外面单引号,里面双引号,然后方法参数给转义的单引号即可(看下面的onClick事件即可)
//刷新二级信号表格(增删改操作后) function reloadSignal(subId) { //清空 $("#msgAll"+subId).empty(); //js手工添加表格 var htmlStart= '<span style="position: absolute; top: 6px; right: 55px; font-weight: bold;">'+ '<a style="font-size: 20px" class="handleAddA" onClick="hideMsg(\'msg'+subId+'\')" href="javascript:void(0);">-</a>'+ '</span>'+ '<span style="position: absolute; top: 8px; right: 85px; font-weight: bold;"> <a style="font-size: 18px" class="handleAddA" onClick="showMsg(\'msg'+subId+'\')" href="javascript:void(0);">+</a>'+ '</span>'+ '<span style="position: absolute; top: 12px; right: 5px; font-weight: 400;"> <a class="handleAddA" onClick="manageSubEdit(\''+subId+'\',this)" href="javascript:void(0);">编辑</a>'+ '</span>'+ '<div style="display: none; width: 600px; left: 0px; position: absolute; top: 32px; z-index: 999" id="msg'+subId+'">'+ '<table style="margin: 0 auto; ">'; var htmlMiddle=''; var arr = [1,2,3]; for (var k = 0, length = arr.length; k < length; k++) { htmlMiddle+= '<tr>'+ '<td>'+k+'</td>'+ '<td>'+k+'</td>'+ '</tr>'; } var htmlEnd='</table>'+'</div>'; $("#msgAll"+subId).html(htmlStart+htmlMiddle+htmlEnd); }
标签:htmlMiddle,双引号,js,subId,length,拼接,var From: https://www.cnblogs.com/rdchen/p/17814719.html