radio单选框选中状态下让对应选中的文字改变颜色

<!DOCTYPE html> <html lang="en"> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script> <style type="text/css"> .radio {...
<!DOCTYPE html>
<html lang="en">
	<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
	<style type="text/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;
		}
	</style>
	<body>
		<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>
	</body>

	<script>
		$(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');
				}
			});
		 
			});
		});
	</script>
</html>
attachments-2020-06-v9UxFomp5ef76ad972e1a.png

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

651 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章