ラジオボタンが選択されたら、ラジオボタンのテキストを変更しようとしています。私はそれが機能しているので、ラジオボタンがチェックされている場合は親にクラスを追加します。今度は、親内のスパンのテキストを変更する部分が必要です(テキスト「選択」を「選択済み」に変更する場合)ラジオボタンがチェックされています)。これが私のコードです:
$(document).ready(function(){
//add the Selected class to the checked radio button
$('input:checked').parent().addClass("selected");
//If another radio button is clicked, add the select class, and remove it from the previously selected radio
$('input').click(function () {
$('input:not(:checked)').parent().removeClass("selected");
$('input:checked').parent().addClass("selected");
});
});
<td><div class="selectBtn">
<input type="radio" name="group1" id="one" value="Falcon Air Trust">
<span class="selectTxt">Select</span></div></td>
<td><div class="selectBtn">
<input type="radio" name="group1" value="Atlantic Aviation">
<span class="selectTxt">Select</span></div></td>
<td><div class="selectBtn">
<input type="radio" name="group1" value="Reliance Aviation">
Select</div></td>