make checkbox behave like radio buttons with javascript

前端 未结 11 755
迷失自我
迷失自我 2020-11-28 06:28

I need to manipulate the behavior of the check boxes with javascript. They should basically behave like radio buttons (only one selectable at a time, plus unselect any previ

11条回答
  •  悲哀的现实
    2020-11-28 07:21

    
    
    
    
    Radio 1:
    Radio 2:

    Ultimately you can use brackets with the name attribute to create an array of radio input like so:

    Radio 1
    Radio 2
    Radio 3
    Radio 4
    

    What matters to transfer in the end are whats in the value attribute. Your names do not have to be different at all for each radio button. Hope that helps.

提交回复
热议问题