假设有3行,因此有3个不同的单选按钮名称,每个名称都有另外5个不同值的单选按钮。
代码:
A B C
apple ball allbad-cat
apple ball allgood-car
dog bark allbad-pet
bull
dull
dog bark allgood-pet
答案 0 :(得分:1)
$("button").click(function() {
var $rows = $("table tr");
var $checked = $rows.find("input:checked");
var remaining = $rows.length - $checked.length;
if(remaining > 0)
alert("answer all the questions: " + remaining + " remaining")
else
alert("sending info")
});
$(function() {
$("button").click(function() {
var $rows = $("table tr");
var $checked = $rows.find("input:checked");
var remaining = $rows.length - $checked.length;
if(remaining > 0)
alert("answer all the questions: " + remaining + " remaining")
else
alert("sending info")
});
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<td width="19">1</td>
<td colspan="4"> question</td>
<td width="42"><Input type="Radio" id="1" Name="point1" value="1" />1</td>
<td width="42"><Input type="Radio" id="2" Name="point1" value="2" />2</td>
<td width="42"><Input type="Radio" id="3" Name="point1" value="3" />3</td>
<td width="42"><Input type="Radio" id="4" Name="point1" value="4" />4</td>
<td width="42"><Input type="Radio" id="5" Name="point1" value="5" />5</td>
<br />
</tr>
<tr>
<td width="19">2</td>
<td colspan="4"> question</td>
<td width="42"><Input type="Radio" id="1" Name="point2" value="1" />1</td>
<td width="42"><Input type="Radio" id="2" Name="point2" value="2" />2</td>
<td width="42"><Input type="Radio" id="3" Name="point2" value="3" />3</td>
<td width="42"><Input type="Radio" id="4" Name="point2" value="4" />4</td>
<td width="42"><Input type="Radio" id="5" Name="point2" value="5" />5</td>
<br />
</tr>
<tr>
<td width="19">3</td>
<td colspan="4"> question</td>
<td width="42"><Input type="Radio" id="1" Name="point3" value="1" />1</td>
<td width="42"><Input type="Radio" id="2" Name="point3" value="2" />2</td>
<td width="42"><Input type="Radio" id="3" Name="point3" value="3" />3</td>
<td width="42"><Input type="Radio" id="4" Name="point3" value="4" />4</td>
<td width="42"><Input type="Radio" id="5" Name="point3" value="5" />5</td>
<br />
</tr>
</table>
<button>submit</button>
&#13;
答案 1 :(得分:0)
<script language="javascript">
$(function() {
$("button").click(function() {
var $rows = $("table tr");
var $checked = $rows.find("input:checked");
var remaining = $rows.length - $checked.length;
if(remaining > 0)
alert("answer all the questions: " + remaining + " remaining")
else
alert("sending info")
});
})