关于javascript中的输入名称

关于javascript中的输入名称,javascript,jquery,html,Javascript,Jquery,Html,使用jquerymobile和javascript,我试图制作一个小测验,它可以在智能手机上运行。它还没有完全完成 我正试图创建一个单选按钮列表,其中一个选择的值将被带入并提交,但当这是一个选项时,为什么输入名称是“radio=choice-v-6” <script type="text/javascript"> var answer1 = 2; function submit() { if ($('input[name=radio-choice-v-6]:checked',

使用jquerymobile和javascript,我试图制作一个小测验,它可以在智能手机上运行。它还没有完全完成

我正试图创建一个单选按钮列表,其中一个选择的值将被带入并提交,但当这是一个选项时,为什么输入名称是“radio=choice-v-6”

<script type="text/javascript">
var answer1 = 2;
function submit()
{ 
   if ($('input[name=radio-choice-v-6]:checked', '#myForm').val() == answer1)
   {
  alert("Correct");
  window.location = "#question-2"
   } 
   else 
   {
   alert("Incorrect");
   window.location = "#incorrect"
   }
}
</script>

var answer1=2;
函数提交()
{ 
if($('input[name=radio-choice-v-6]:选中','#myForm')。val()==answer1)
{
警惕(“正确”);
window.location=“#问题-2”
} 
其他的
{
警告(“不正确”);
window.location=“#不正确”
}
}
然后,当我使用jquerymobile预设按钮名称时,我会使用它

<form id="myForm" name="myForm">
      <fieldset data-role="controlgroup" id="radiobuttons" data-mini="true">
        <input name="radio-choice-v-6" id="radio-choice-v-6a" type="radio" onclick="question1()" value="1">
        <label for="radio-choice-v-6a">One</label>
        <input name="radio-choice-v-6" id="radio-choice-v-6b" type="radio" onclick="question1()" value="2">
        <label for="radio-choice-v-6b">Two</label>
        <input name="radio-choice-v-6" id="radio-choice-v-6c" type="radio" onclick="question1()" value="3">
        <label for="radio-choice-v-6c">Three</label>
    </fieldset>
  <td><button type="submit" id="submit" name="submit" value="Submit" onclick="submit()"></td>
  </form>

一个
两个
三
我想我会将输入名称设置为“单选按钮”或“myForm”


我不熟悉JavaScript,想知道为什么“radio-choice-v-6”可以工作。

'input[name=radio-choice-v-6]:checked'是选择器,只针对选中的单选按钮,其名称为
radio-choice-v-6
。表单通常不能被视为已选中,字段集也不能。因此
myForm
radiobuttons
不会以当前选中的单选按钮为目标