radio选中状态对应文字改变颜色

来源:互联网 发布:php 判断语句 编辑:程序博客网 时间:2024/05/17 14:28

效果:

html:

<input type="radio" class="radio" name="apply" value="" checked="checked" /><lable class="radio-font" for="apply">本人申请</lable><input type="radio" class="radio" name="apply" value="" /><label class="radio-font" for="apply">代替他人申请</label>
css:

.radio {width: 18px;height: 18px;border: 2px solid #649723;margin-top: 20px;}.radio-font {font-size: 18px;margin-right: 25px;color:#767676;margin-top: 20px;}
js:

$(document).ready(function (){$("input[type='radio']").first().next().css('color','#649723');//设置默认选项的文字为选中状态$(":radio").click(function (){$("input[type='radio']").each(function(){if(this.checked){$(this).next().css('color','#649723');}else{$(this).next().css('color','#767676');}});});});




0 0
原创粉丝点击