How can I toggle radiobutton

后端 未结 7 1131
一向
一向 2020-12-31 03:57

Say this is my HTML:



         


        
7条回答
  •  旧巷少年郎
    2020-12-31 04:41

    Using @Goran Mottram answer just tweaking it a bit to suit the case where radio buttons are not siblings.

    $(".accordian-radio-button").click(function(){
        var wasChecked = true;
        if($(this).data('waschecked') == true){
            $(this).prop('checked', false);
            wasChecked = false;
        }
        $('input[name="ac"]').data('waschecked', false);
        $(this).data('waschecked', wasChecked);
    })
    
    
    

提交回复
热议问题