-
表单中的Radio单选框切换效果,当选中某个单选框的时候,所属范围会一同变换,我觉得大家应该收藏一下,以前想用的时候苦苦叫不上这种效果的名字,现在长到了,而且实现起来竟然如此简单,有些地方要注意,获取标签名为myradio的标签。
-
<!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=gb2312\" />
-
<title>Radio切换效果</title>
-
<style>
-
*{margin:0;padding:0;}
-
body{margin:50px;font-size:12px;color:#666;}
-
li{list-style:none;}
-
div{width:210px;}
-
#tab1 ,#tab2{width:398px;height:34px;border:1px #cfedff solid;border-bottom:0;background:url(images/title.gif) repeat-x;}
-
#tab1 ul ,#tab2 ul{margin:0;padding:0;}
-
#tab1 li,#tab2 li{float:left;padding:0 30px;height:34px;line-height:34px;text-align:center;border-right:1px #ebf7ff solid;cursor:pointer;}
-
#tab1 li.now,#tab2 li.now{color:#5299c4;background:#fff;font-weight:bold;}
-
.tablist{width:378px;height:100px;padding:10px;font-size:14px;line-height:24px;border:1px #cfedff solid;border-top:0;display:none;}
-
.block{display:block;}
-
</style>
-
</head>
-
<body>
-
<h1>Radio切换</h1>
-
<style type=\"text/css\">
-
fieldset{width:378px;border:1px #B0C0D1 solid;padding:10px;}
-
legend{background:#B0C0D1;padding:4px 10px;color:#fff;}
-
#c{margin-top:10px;}
-
.c1,.c2{width:378px;line-height:20px;}
-
.c1{color:#014CC9;}
-
.c2{color:#7E6095;}
-
h3{font-size:16px;padding:5px 0;}
-
.red{color:#BD0A01;}
-
</style>
-
<script type=\"text/javascript\">
-
function radioShow(){
-
var myradio=document.getElementsByName(\"myradio\");
-
var div=document.getElementById(\"c\").getElementsByTagName(\"div\");
-
for(i=0;i<div.length;i++){
-
if(myradio[i].checked){
-
div[i].style.display=\"block\";
-
}
-
else{
-
div[i].style.display=\"none\";
-
}
-
}
-
}
-
</script>
-
<form name=\"ck\">
-
<fieldset>
-
<legend>I\
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29737856/viewspace-1226042/
,如需转载,请注明出处,否则将追究法律责任。