Bootstrap: set initial radio button checked in HTML

后端 未结 3 480
故里飘歌
故里飘歌 2021-01-01 14:22

I\'m using Bootstrap\'s JavaScript buttons to style some radio buttons, and I don\'t seem to be able to set an initial button as checked.

Here is my code:

3条回答
  •  悲&欢浪女
    2021-01-01 14:54

    If you're using the HTML 5 doctype, just use checked without any value:

    
    

    checked="checked" should work as well, so you'll have to clarify what's not working for you.

    • Having a checked attribute on the input will ensure correct state on the form field
    • Adding an active class on the label will set the correct visual state

    Reference documentation.

提交回复
热议问题