您的位置:首页 > 其它

点击文字选中单选按钮方法(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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: