JSFiddle - React, Tailwind, and code Playground
HTML
<fieldset>
<legend>Q1.あなたの好きな動物は?(◯はラジオボタンです)</legend>
<label><input type="radio" name="c1" value="1" /> 犬</label>
<label><input type="radio" name="c1" value="2" /> 猫</label>
<label><input type="radio" name="c1" value="3" /> 鳥</label>
</fieldset>
<fieldset>
<legend>Q2.あなたの好きな食べ物は?</legend>
<label><input type="radio" name="c2" value="1" /> ハンバーグ</label>
<label><input type="radio" name="c2" value="2" /> グラタン</label>
<label><input type="radio" name="c2" value="3" /> スパゲッティ</label>
</fieldset>
<fieldset>
<legend>Q3.あなたの好きな色は?</legend>
<label><input type="radio" name="c3" value="1" /> 赤</label>
<label><input type="radio" name="c3" value="2" /> 青</label>
<label><input type="radio" name="c3" value="3" /> どどめ色</label>
</fieldset>
<button id="check">Check</button>
<div id="result"></div>
JavaScript
$(function(){
$radio = $(':radio');
//$radio.click(check);//チェックと連動させる
$('#check').click(check);//診断ボタン押させる
function check(){
var total = 0;
var result = '';
$radio.filter(':checked').map(function(){
total += Number(this.value);
});
if (total > 6) {
result = 'キタ━(゚∀゚)━!';
} else if( total > 3 ) {
result = '(・∀・)イイ!';
} else if( total > 0) {
result = '( ´_ゝ`)';
} else {
result = '何も選択されていません';
}
$('#result').html(result);
}
});