我正在尝试更改单选按钮上的文本,一旦它被选中。我让它工作了,所以如果选中单选按钮,我会向父级添加一个类,现在只需要更改父级内跨度文本的部分(如果单选按钮被选中)。这是我的代码:
$(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>