关于在js中 拼接Html.写方法 传参数的方式.
开发项目中经常在js里面,拼接一段含有方法的Html标签,然后添加到页面中. 拼接的方式如果不规范,可能导致页面表头报错 ....UNfind. 在此留下正确的书写方式.
function AjaxChannelFinancialList() {
//条件: page state
$.ajax({
url: "@Url.Action("AjaxChannelFinancialList", "FinancialCenter")",
type: "GET",
cache: false,
contentType: "application/json; charset=utf-8",
data:
{
Page: 1,
PageCount: 10,
MeranctName: $.trim($('#MeranctName').val()),
ChannelName: $('#ChannelName').val(),
SelType: $("#SelType").val()
},
success: function (data) {
var objs = data;
if (objs == null || objs.Data == null) {
$("#table_bug_report").html("<div colspan=\"88\">暂无数据</div>");
}
else {
var Html = "";
var data = objs.Data;
for (var i = 0; i < objs.Data.length; i++) {
Html += '<div style="width:100%; height:46px; position:relative">'
Html += '<div class="content_1">'
Html += '<span class="img_name" style=""><img src="/img/touxiang.png" /></span>'
Html += '<span class="name">' + data[i].MerchantName + '</span>'
Html += '<span class="fukuan" style=" ">状态:' + data[i].StateName + '</span>'
Html += '</div></div>'
//财务明细内容
Html += '<div class="list_of" style="width:100%;height:130px;">'
Html += "<div class='pic'><img src=\"/img/meituwaimai.png\" onclick=\"ViewFinancialCenter('" + data[i].MerchantCode + "','" + data[i].ChannelId + "')\"/></div>"
Html += '<div class="list_1">'
Html += '<ul class="nerrong" style="list-style:none">'
Html += '<li style="font-size:18px; color:rgba(0, 0, 0, 0.8)">' + data[i].OTAName + '</li>'
Html += '<li>信用额度:' + data[i].LineCredit + '¥</li>'
Html += '<li>占用额度:' + data[i].Takeupamount + '¥</li>'
Html += '<li>押金金额:' + data[i].deposit + '¥</li>'
Html += '<li>发布时间:' + data[i].UpdateTimeStr + '</li>'
Html += '</ul>'
Html += "<div style=\'font-size:16px;margin-left:200px;margin-top:-120px; position:absolute;height:60px;width:50px'>"
Html += "<span onclick=\"RechargeFinancialCenter("+ data[i].Id+");\"> 充值</span></div>"
Html += "<div style=\'font-size:16px;margin-left:240px;margin-top:-120px; position:absolute;height:60px;width:50px'>"
Html += "<span onclick=\"EditFinancialCenter("+ data[i].Id +");\">编辑</span></div>"
Html += '</div>'
Html += '</div>'
//总金额
Html += '<div style="width:100%; height:35px; border-bottom:1px solid #ddd;">'
Html += '<span style="float:right; line-height:35px; margin-right:10px;">余额:' + data[i].balance + '¥</span>'
Html += '</div>'
Html += '</div>'
}
$("#table_bug_report").html(Html);
}
}
});
}