数组中的Jquery选择器字符串不';我好像没被认出来

数组中的Jquery选择器字符串不';我好像没被认出来,jquery,forms,jquery-selectors,radio-button,Jquery,Forms,Jquery Selectors,Radio Button,我有多个divid=“p-1”,id=“p-2”,其中每个div包含一组不同的单选按钮 单击submit按钮时,我会检查是否选择了单选按钮并相应地继续 我的问题:没有选择单选按钮,我被困在警报(“未检查任何内容”)-我怀疑if(!$)(pArray[pArrayIndexCount]+“input[name='options radios']:checked”).val()/数组中的选择器是个问题,因为对div进行硬编码的工作方式如下:if(!$)(#p-1 input[n.-有什么想法吗 JS

我有多个div
id=“p-1”
id=“p-2”
,其中每个div包含一组不同的单选按钮

单击submit按钮时,我会检查是否选择了单选按钮并相应地继续

我的问题:没有选择单选按钮,我被困在
警报(“未检查任何内容”)
-我怀疑
if(!$)(pArray[pArrayIndexCount]+“input[name='options radios']:checked”).val()
/数组中的选择器是个问题,因为对div进行硬编码的工作方式如下:
if(!$)(#p-1 input[n.
-有什么想法吗

JS:

HTML:


文本
文本
提交
文本
文本
提交
缺少(#)-
p-1
是包装器元素的id,因此需要将其与id选择器一起使用

$('#' + pArray[pArrayIndexCount]+" input[name='optionsRadios']:checked")
编写if条件的另一种方法是

if (!$('#'+ pArray[pArrayIndexCount]+" input[name='optionsRadios']").is(':checked')) {
缺少(#)-
p-1
是包装器元素的id,因此需要将其与id选择器一起使用

$('#' + pArray[pArrayIndexCount]+" input[name='optionsRadios']:checked")
编写if条件的另一种方法是

if (!$('#'+ pArray[pArrayIndexCount]+" input[name='optionsRadios']").is(':checked')) {
缺少(#)-
p-1
是包装器元素的id,因此需要将其与id选择器一起使用

$('#' + pArray[pArrayIndexCount]+" input[name='optionsRadios']:checked")
编写if条件的另一种方法是

if (!$('#'+ pArray[pArrayIndexCount]+" input[name='optionsRadios']").is(':checked')) {
缺少(#)-
p-1
是包装器元素的id,因此需要将其与id选择器一起使用

$('#' + pArray[pArrayIndexCount]+" input[name='optionsRadios']:checked")
编写if条件的另一种方法是

if (!$('#'+ pArray[pArrayIndexCount]+" input[name='optionsRadios']").is(':checked')) {
您缺少选择器中的
#

此外,您可能希望将代码放入循环中,因为您似乎正在递增
pArrayDefaultIndex
,但您的代码将只被调用一次。我个人建议在它们上放置一个类,而不是ID,并使用类似于

$(".yourclass").each(function(){
    // Find your input element in relation to this object
});
这将在与该选择器匹配的所有元素上执行对象,即具有类的所有元素
yourclass
您缺少选择器中的
#

此外,您可能希望将代码放入循环中,因为您似乎正在递增
pArrayDefaultIndex
,但您的代码将只被调用一次。我个人建议在它们上放置一个类,而不是ID,并使用类似于

$(".yourclass").each(function(){
    // Find your input element in relation to this object
});
这将在与该选择器匹配的所有元素上执行对象,即具有类的所有元素
yourclass
您缺少选择器中的
#

此外,您可能希望将代码放入循环中,因为您似乎正在递增
pArrayDefaultIndex
,但您的代码将只被调用一次。我个人建议在它们上放置一个类,而不是ID,并使用类似于

$(".yourclass").each(function(){
    // Find your input element in relation to this object
});
这将在与该选择器匹配的所有元素上执行对象,即具有类的所有元素
yourclass
您缺少选择器中的
#

此外,您可能希望将代码放入循环中,因为您似乎正在递增
pArrayDefaultIndex
,但您的代码将只被调用一次。我个人建议在它们上放置一个类,而不是ID,并使用类似于

$(".yourclass").each(function(){
    // Find your input element in relation to this object
});
这将在与该选择器匹配的所有元素上执行对象,即具有类
yourclass