像下面这行代码在加div的时候
html += '<div class="including">包含本金' + v.Principal + '元+利息' + v.Interest + '元</div>'
html += '<div class="including">包含本金 onclick="方法名称()"' + v.Principal + '元+利息' + v.Interest + '元</div>'
这样写。
可如果onclick要加上参数呢就要这样写:
html += "<div class=\"paybutton\" onclick=\"javascript:rePay('" + v.Id + "')\" style=\"color:" + textcolor + "\">" + buttonText + "</div>";
然后在repay()这个方法里 带着参数id跳转到其他页面
///点击去还款按钮
function rePay(orderid) {
return;
window.location.href = "topay.html?id=" + orderid;
}
然后在topay页面中用 getQueryString()方法处理下,得到传来的参数
//获取url传值数据
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null && r[2] != "false")
return unescape(r[2]);
return false;
}
然后在用参数做一系列的操作。