我有一堆無線電的。這裏是它們的代碼:當選擇1收音機,檢查所有其他人的價值
<div class="question">18 years old or older?</div>
<div class="radios">
<input type="radio" name="age" value="yes"> Yes
<input type="radio" name="age" value="no"> No
<div class="tooltip"><span>Sorry, you must be 18 years old or older.</span></div>
</div>
<div style="clear: both;"></div>
<div class="question">Earn $1,600 or more each month?</div>
<div class="radios">
<input type="radio" name="earn" value="yes"> Yes
<input type="radio" name="earn" value="no"> No
<div class="tooltip"><span>Sorry, you must earn $1,600 or more each month.</span></div>
</div>
<div style="clear: both;"></div>
<div class="question">Stable in your job and residence?</div>
<div class="radios">
<input type="radio" name="stable" value="yes"> Yes
<input type="radio" name="stable" value="no"> No
<div class="tooltip"><span>Sorry, you must be stable in your job and residence.</span></div>
</div>
<div style="clear: both;"></div>
<div class="question">No reposessions within 1 year?</div>
<div class="radios">
<input type="radio" name="repo" value="yes"> Yes
<input type="radio" name="repo" value="no"> No
<div class="tooltip"><span>Sorry, you must have no reposessions within 1 year.</span></div>
</div>
<div style="clear: both;"></div>
當有人點擊其中任何一種電臺
,我想它來檢查,看是否所有的無線電值都是「是」或沒有。
如果他們是肯定的,我希望它提醒「所有是的!」
繼承人我的代碼不工作:
$('.radios input').mousedown(function() {
if ($(this).val() == 'no')
$(this).closest('.radios').find('.tooltip').show();
else
$(this).closest('.radios').find('.tooltip').hide();
$yescount = 0;
$('.radios input').each(function() {
if ($(this).val() == 'yes')
$yescount += 1;
});
if ($yescount == 4)
alert('all yes');
});
任何幫助將是巨大的。
即使並非所有收音機都設置爲「是」,它似乎仍在提醒。
完美的作品。非常感謝。將盡快接受。 – scarhand