テーブルにラジオ ボタンとチェックボックスが埋め込まれたフォームがいくつかあります。jquery を使用して 2 つのことを行う必要があります。
まず、ユーザーは、ボタンを含むテーブル セルをクリックして、ラジオ ボタンまたはチェックボックスを「クリック」できます。
次に、ユーザーは2 回クリックして、チェックボックスとラジオ ボタンを切り替えることができます。したがって、すでにチェックされているラジオ ボタン (またはそれを含むセル) をクリックすると、チェックが解除され、グループ内でラジオ ボタンが選択されなくなります。
私はこれらの両方を別々に行うことができますが、それらを一緒に機能させることに固執しています。助けてください!
これが私のあまり機能しないjqueryコードです:
$(".clickable", Q)
.mouseover( function(){ $(this).addClass('mouseover-cell'); })
.mouseout( function(){ $(this).removeClass('mouseover-cell'); })
.click( function(event){
if( event.target.type != 'checkbox' && event.target.type != 'radio' ){
var x = $('input', this).attr("checked");
$('input', this).attr("checked", !x);
//$('input', this).trigger("click");
}
return false;
});
1 つのボタンの html は次のようになります。
<tr>
<td>
Label for the button group
</td>
<td class="clickable">
<input type="radio" name="q1" value="1">
</td>
<td class="clickable">
<input type="radio" name="q1" value="2">
</td>
<td class="clickable">
<input type="radio" name="q1" value="3">
</td>
</tr>