How do I get the label of the selected radio button using javascript

后端 未结 2 1986
囚心锁ツ
囚心锁ツ 2020-12-21 07:31

I have the following HTML

2条回答
  •  难免孤独
    2020-12-21 07:58

    You have to access the corresponding label separately, since it resides in a separate tag. Because the labels' for attribute is equal to its option's id, you can get to the label easily:

    for(var i=0; i

    Also check out this fiddle

提交回复
热议问题