在jquery和ajax中处理单选按钮值和文本

在jquery和ajax中处理单选按钮值和文本,jquery,Jquery,我正在尝试获取单选按钮的文本,并将其设置为的文本。另外,我想在ajax中传递单选按钮的值 以下是模板: <div id="div_id_feature_selection" class="form-group"> <label for="id_feature_selection_0" class=" requiredField"> Featur

我正在尝试获取单选按钮的文本,并将其设置为的文本。另外,我想在ajax中传递单选按钮的值

以下是模板:

   <div id="div_id_feature_selection" class="form-group">
        <label for="id_feature_selection_0" class=" requiredField">
              Feature selection<span class="asteriskField">*</span>
        </label>
        <div class="">
             <div class="form-check">
                 <input type="radio" class="form-check-input" name="radio_selection" id="id_radio_selection_1" value="rdoSel1" >
                 <label for="id_radio_selection_1" class="form-check-label">
                      Radio Selection 1
                 </label>
             </div>

             <div class="form-check">
                 <input type="radio" class="form-check-input" name="radio_selection" id="id_radio_selection_2" value="rdoSel2" >
                 <label for="id_radio_selection_2" class="form-check-label">
                      Radio Selection 2
                 </label>
             </div>

             <div class="form-check">
                 <input type="radio" class="form-check-input" name="radio_selection" id="id_radio_selection_3" value="rdoSel3" >
                 <label for="id_radio_selection_3" class="form-check-label">
                      Radio Selection 3
                 </label>
             </div>
        </div>
   </div>
我试图将下面的代码放在顶部,但只检索到第一个单选按钮的值。 如果顶部没有这一行,单击事件将不起作用

   sel_technique = $("input[name='feature_selection']:checked").val();

首先,您提到您正在尝试使用引用
feature\u selection
但在HTML中不存在的代码

$("input[name='radio_selection']").change(function(){
    $("#rdo_text_copy").text($("input[name='radio_selection']:checked").next("label").text());
});
您可以使用
next
来获取
radio
后面的标签,而不是混淆收音机的
文本,因为这是HTML的模式

$("input[name='radio_selection']").change(function(){
    $("#rdo_text_copy").text($("input[name='radio_selection']:checked").next("label").text());
});
$("input[name='radio_selection']").change(function(){
    $("#rdo_text_copy").text($("input[name='radio_selection']:checked").next("label").text());
});