Js脚本没执行,why?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/initial.css"/>
<link rel="stylesheet" type="text/css" href="css/单选按钮美化.css"/>
<script type="text/javascript">
function show(index){
var list=document.getElementsById("type").getElementsByTagName("li");
// var list=document.getElementsById("type").getElementsByClassName("radio");
for(var i=1; i<list.length;i++){
if(index==i){
// list[i].className.addClass("selected");
list[i].className="radio selected";
}
else{
// list[i].className.removeClass("selected");
list[i].className="radio";
}
}
}
</script>
</head>
<body>
<div>
<ul id="type">
<li>配送类型</li>
<li class="radio selected" onclick="show(1)"><a href="#"><b></b>全部</a></li>
<li onclick="show(2)"><a href="#"><b></b>京东配送</a></li>
<li onclick="show(3)"><a href="#"><b></b>第三方配送</a></li>
</ul>
</div>
</body>
</html>
css文件
div.container{
width: 400px;
height: 32px;
border: 1px solid #dfdfdf;
margin: 30px auto 0;
}
ul{
height: 32px;
line-height: 32px;
padding-left: 15px;
list-style-type: none;
}
ul li{
display: inline-block;
float: left;
}
li.radio{
/*border: 1px solid #ff0000;*/
margin: 0 10px 0 8px;
padding-left: 23px;
position: relative;
/*给radio设置position相对布局后,
其中的子元素b设置position绝对布局后才会以该li为包含块进行位置调整*/
}
li.radio a{
color: #000000;
text-decoration: none;
}
li.radio a:hover{
color: #cc0000;
text-decoration: underline;
/*当鼠标移动到a超链接上时链接文字变成红色同时加下划线*/
}
li.radio a b{
display: block;
width: 20px;
height: 20px;
position: absolute;
left: 0;
top: 6px;
background: url("../img/singleRadio.gif") no-repeat;
background-position: -15px -18px;
}
li.radio a:hover b{
background-position: -15px -118px;
/*当鼠标移动到a超链接上时b按钮图片变成闪光状态*/
}
li.selected a b,li.selected a:hover b{
background-position: -15px -218px;
}我写的Js脚本为什么没执行成功呢,求大神帮忙!