在绑定页面中有的需要加点击事件 ,点击事件中如果要传参的写法和带着参数跳转到另一个页面

 像下面这行代码在加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;
}

然后在用参数做一系列的操作。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值