現在、select html要素のドロップダウンリストから値テストを選択すると、チェックボックスのグループをバインドする以下のjQueryスクリプトがあります。結果として、チェックボックスはラジオボタンのように動作し、一度に1つのチェックボックスをチェックすることができます。私の問題は、テスト値が選択された後、選択ボックスから別の値を選択するときにラジオボタンをデフォルトの動作に戻す必要があることです。どんな助けでも大歓迎です。私の下のjavascriptとhtmlコードを見てください。JQueryを使用してチェックボックスグループのバインドを解除する
$('select').on('change', function() {
$('input.example').prop('checked', false);
if(this.value == 'test')
{
alert("Hello");
$('input.example').bind('change', function() {
$('input.example').not(this).attr('checked', false);
});
}
else if(this.value != 'test')
{
alert("Bye");
$('input.example').unbind('change', function() {
$('input.example').not(this).attr('checked', false);
});
}
});
<select id="myselect" name="action">
<option value="" selected="selected">-------------</option>
<option value="deleted_selected">Delete selected Clients</option>
<option value="test">Test</option>
</select>
<button type="submit" class="button" title="Run the selected action" name="index" value="0">Go</button>
<br><br>
<input type="checkbox" class="example" />
<input type="checkbox" class="example" />
<input type="checkbox" class="example" />
<input type="checkbox" class="example" />