ラジオボタンがいっぱいのページがあり、「成功:すべての質問を完了しました」とは表示されません。
html:
Question 1:
Question 2:
<div id="display">0</div>
スクリプト:
$('#display').each(function(){
if($(':radio[name=income]:checked, :radio[name=debt]:checked').length == 2)
$("#display").html('
Success: You have completed all questions
You have NOT yet completed all questions
助けていただきありがとうございます。
ベストアンサー
私が正しく理解していれば、あまりコードは必要ありません。
以下のコードを試してください..
$('input').live('change',function()
{
if($(':radio:checked').size() > 1)//One is number of Questions-1 in your case..
{
$('#display').html('Answered all.')
}
});
ラジオボタンのグループごとに1つの回答しかできないので、チェックされたラジオボタンのサイズをチェックするだけです。
ここで働いているのはフィドルです
http://jsfiddle.net/C7NmD/4/