点击文字选中单选按钮方法(for)
2013-04-05 12:25
375 查看
方法一:
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<form>
<label for="zzjs">姓名</label>
<input type="radio" id="zzjs" value="123" name="name">
<label for="zzjs.net">密码</label>
<input type="radio" id="zzjs.net" value="456" name="name">
</form>
</body>
</html>
方法2:
不使用js实现点击radio旁边的文字选中radio。把radio设置成inline-block,然后设置radio大小再在里面放上文字不就行了。本来想在里面放文字但发现不行。所以就用绝对定位把文字放在里面。再把文字设置在radio的下一层就行了。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Feed Viewer</title>
<style type="text/css">
</style>
<script>
</script>
</head>
<body>
<input style="width:200px;padding-right:100px" type="radio" name="sex" value="male"/>
<p style="position:absolute;left:120px;top:-10px;z-index:-1;">click me</p>
</body>
</html>
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<form>
<label for="zzjs">姓名</label>
<input type="radio" id="zzjs" value="123" name="name">
<label for="zzjs.net">密码</label>
<input type="radio" id="zzjs.net" value="456" name="name">
</form>
</body>
</html>
方法2:
不使用js实现点击radio旁边的文字选中radio。把radio设置成inline-block,然后设置radio大小再在里面放上文字不就行了。本来想在里面放文字但发现不行。所以就用绝对定位把文字放在里面。再把文字设置在radio的下一层就行了。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Feed Viewer</title>
<style type="text/css">
</style>
<script>
</script>
</head>
<body>
<input style="width:200px;padding-right:100px" type="radio" name="sex" value="male"/>
<p style="position:absolute;left:120px;top:-10px;z-index:-1;">click me</p>
</body>
</html>
相关文章推荐
- 点击单选按钮radio后面的文字即可选中单选按钮
- 点击单选按钮radio后面的文字即可选中单选按钮
- html中点击radio后的文字相当于选中该单选按钮如何实现?怎么实现两个redio,选中一个,取消另一个?
- 点击单选按钮radio后面的文字即可选中单选按钮
- 点击单选按钮radio后面的文字即可选中单选按钮
- 实现点击单选按钮后面的文字说明自动选中相应单选按钮功能
- radio按钮点击文字选中按钮
- javascript实现点击后变换按钮显示文字的方法
- 单选按钮radio点击已选中的,取消选中
- 点击单选按钮后的文字即可选定对应单选按钮
- 单选按钮radio点击已选中的取消选中 。
- 点击文字选中的单选和复选框
- 记录 单选全部按钮后选中全选按钮的方法
- Jquery 获取单选按钮组选中的值的方法
- jQuery实现点击单选按钮切换选中状态效果
- IE下单选按钮隐藏后点击对应label无法选中的bug解决
- 按钮文字选中与点击变动色
- 微信小程序实现动态设置placeholder提示文字及按钮选中/取消状态的方法
- jquery判断单选按钮radio是否选中的方法
- jquery判断单选按钮radio是否选中的方法