How to get value of selected radio button?

前端 未结 28 2265
温柔的废话
温柔的废话 2020-11-22 03:51

I want to get the selected value from a group of radio buttons.

Here\'s my HTML:

28条回答
  •  旧巷少年郎
    2020-11-22 04:42

    If the buttons are in a form
    var myform = new FormData(getformbywhatever); myform.get("rate");
    QuerySelector above is a better solution. However, this method is easy to understand, especially if you don't have a clue about CSS. Plus, input fields are quite likely to be in a form anyway.
    Didn't check, there are other similar solutions, sorry for the repetition

提交回复
热议问题