两个功能没有运行OnClick?

时间:2019-01-13 11:50:22

标签: javascript html

单击我的按钮时,我要运行两个功能。选择按钮变大(正在运行),但是我还希望底部的“注册”按钮的值更改为“注册为黄金”。但是,这不起作用,如果有人可以帮助使这两个功能运行,那就太好了! :)

https://jsfiddle.net/u0n6v8zr/

<div class="homepagemembershippricingtable">
  <ul class="price">
    <li class="homemembershiptableheader">Platinum</li>
    <li class="homemembershiptableprice"><p class="membershippricetext">£10</p> / month</li>
    <li class="homemembershiptablecredits">3 credits, monthly</li>
    <li class="membershipchoosebutton"><button type="button" class="chooseemembershipbutton" onClick="setusermembershipchoice('Platinum');setmembershipayment()">Choose</button></td>
  </ul>
</div>

1 个答案:

答案 0 :(得分:0)

函数setmembershipayment未关闭,因此浏览器由于发现错误而无法运行该函数。

您忘记了右括号。按照以下示例更新您的函数,它将正常工作。

function setmembershipayment(){
    if (usermembershipchoice == "Silver") {
        alert("PAY FOR SILVER");
        document.getElementById("signupbutton").value = "SIGN UP TO SILVER";
    } else if (usermembershipchoice == "Gold") {
        document.getElementById("signupbutton").value = "SIGN UP TO GOLD";
        alert("PAY FOR GOLD");
    } else if (usermembershipchoice == "Platinum") {
        document.getElementById("signupbutton").value = "SIGN UP TO PLATINUM";
    } else { 
       alert("ERROR");
    } // THE MISSED BRACKED!! ;)
}