<input type="radio" name="a" />
<input type="radio" name="a" />
<input type="radio" name="b" />
<input type="radio" name="b" />
Run Code Online (Sandbox Code Playgroud)
我想确保的both group的radiobutton必须检查,为了这个,我尝试:
if($("input[type=radio,name=a]:checked").length > 0 &&
$("input[type=radio,name=b]:checked").length > 0)
{
/* do something */
}
Run Code Online (Sandbox Code Playgroud)
但不工作,任何人都可以告诉我为什么?
小智 6
if($("input[type=radio][name=a]:checked").length > 0 &&
$("input[type=radio][name=b]:checked").length > 0)
{
/* do something */
}
Run Code Online (Sandbox Code Playgroud)