码迷,mamicode.com
首页 > 其他好文 > 详细

单选按钮和标签组合点击

时间:2019-02-14 13:26:57      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:html   details   ansi   人工智   center   图片   人工智能   att   教程   

1、问题背景

     现在,有个问题:一组单选按钮,点击按钮可以选中,但是点击标签label不能被选中。

 

2、实现源码

(1)点击按钮选中

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>单选按钮和标签组合点击</title>
<script type="text/javascript" src="jquery-1.12.3.js"></script>
<script type="text/javascript"></script>
</head>

<body>
   <div>
      <input type="radio" id="man" name="sex" style="cursor:pointer"/>
      <label style="cursor:pointer"></label>
      <input type="radio" id="woman" name="sex" style="cursor:pointer"/>
      <label style="cursor:pointer"></label>
   </div>
</body>
</html>

(2)点击label选中

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>单选按钮和标签组合点击</title>
<script type="text/javascript" src="jquery-1.12.3.js"></script>
<script type="text/javascript"></script>
</head>

<body>
   <div>
      <input type="radio" id="man" name="sex" style="cursor:pointer"/>
      <label style="cursor:pointer" for="man"></label>
      <input type="radio" id="woman" name="sex" style="cursor:pointer"/>
      <label style="cursor:pointer" for="woman"></label>
   </div>
</body>
</html>

(3)点击label选中

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>单选按钮和标签组合点击</title>
<script type="text/javascript" src="jquery-1.12.3.js"></script>
<script type="text/javascript"></script>
</head>

<body>
   <div>
      <label style="cursor:pointer"><input type="radio" id="man" name="sex" style="cursor:pointer"/></label>
      <label style="cursor:pointer"><input type="radio" id="woman" name="sex" style="cursor:pointer"/></label>
   </div>
</body>
</html>

3、实现结果

 

(1)点击按钮选中

技术图片

 

(2)点击按钮和label选中

技术图片

 

(3)点击按钮和label选中

技术图片

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

单选按钮和标签组合点击

标签:html   details   ansi   人工智   center   图片   人工智能   att   教程   

原文地址:https://www.cnblogs.com/odejsjhshw/p/10373974.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!