jQuery - checkboxes like radiobuttons

前端 未结 9 1677
小鲜肉
小鲜肉 2020-12-01 11:07

I have group checkboxes and I like if this group have behaviour like radiobuttons with same name atribute.

Each checkbox has different name.

Only one can be

9条回答
  •  情深已故
    2020-12-01 11:36

    HTML

    
    
    
    

    Javascript

    $('input.unique').each(function() {
        $(this).on('touchstart click', function() {
        $('input.unique').not(this).removeAttr('checked');
    });
    });
    

    Fiddle: http://jsfiddle.net/L2ad1vd8/

提交回复
热议问题