选中时,在单选按钮上添加类和更改文本

我试图在单选按钮上更改文本。 我有它工作,所以如果单选按钮被选中,我向父母添加一个类,现在只需要部分更改父母内部的跨度文本(我希望文本“选择”更改为“选定”,如果单选按钮)。 这是我的代码:

$(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"); }); }); 
Select
Select
Select

试试这个

 $(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").find("span").html("Select"); $('input:checked').parent().addClass("selected").find("span").html("Selected"); }); });