如何点击单选按钮检查并取消选中

时间:2018-01-28 06:44:42

标签: javascript jquery

让我解释一下我想要实现的目标。点击标签1将再次显示按钮,我希望按钮禁用与标签2和标签3相同。

JsFiddle - http://jsfiddle.net/yingchor/xjzutbr9/2/

SELECT CASE WHEN SUM([Dollar Value]) > 100
            THEN 'Yes'
            ELSE 'No'
            END As Promotion
FROM [Table]
WHERE ID IN(1, 3)

我应该如何更改脚本以实现这一目标?

1 个答案:

答案 0 :(得分:0)

如果我理解你试试这个:

$('.radio-button').on("click", function(event) {
    var this_input = $(this);
    if (this_input.attr('checked1') == '1') {
        this_input.attr('checked1', '1')
    } else {
        this_input.attr('checked1', '2')
    }

    $('.radio-button').prop('checked', false);
    if (this_input.attr('checked1') == '1') {
        this_input.prop('checked', false);
        this_input.attr('checked1', '2');
        $('.box').hide(); // Hides button in second click
    } else {
        this_input.prop('checked', true);
        this_input.attr('checked1', '1')
    }

});

此处示例:http://jsfiddle.net/xjzutbr9/3/