This is my code:
$("input[name=donationmode]").change(function() {
$(".setpaymentOptions").children().addClass("fadeout");
$(".setpaymentOptions").children().children(".inputfield").children("input").attr("disabled", "disabled");
$(".option-"+$(this).val()).removeClass("fadeout");
$(".option-"+$(this).val()).children(".inputfield").children("input").removeAttr("disabled");
if($(this).val() == 2)
{
$(".option-2").children(".inputfield").children("#paymentOption").find("input").removeAttr("disabled");
$(".option-2").find(".addPaymentOption").attr("onclick", "addPaymentOption()");
}
else
{
$(".option-2").children(".inputfield").children("#paymentOption").find("input").attr("disabled", "disabled");
$(".option-2").find(".addPaymentOption").removeAttr("onclick");
}
});
When I change the input (it's a radio button group of 3 radio buttons) to 2, it will add the onclick to the .addPaymentOption. Then I will change the input to 3 and the onclick disappears. That's good.
Now the tricky part, when I click back on the the with value 2 the onclick doesn't come back.
Please help me, where is the bug?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.