求助取值size()无响应
各位大侠:小弟代码如下:其中就是无法取值size()添加<li>请各位大侠帮小弟答疑解惑啊。。。小弟在这里拜谢了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<title>无标题文档</title>
<style>
*{ padding:0px; margin:0px;list-style:none;}
.banner { width:500px; height:300px; margin:100px auto; border:1px solid #808080; position:relative; overflow:hidden;}
.banner .img{width:5000px; position:absolute; left:0px;top:0px;}
.banner .img img{width:500px; height:300px;}
.banner .img li{float:left;}
.banner .num { position:absolute; width:100%; bottom:10px; left:0px; text-align:center; font-size:0px;}
.banner .num li { width:10px; height:10px; background-color:#888; border-radius:50%;display:inline-block; margin:0px 3px; cursor:pointer;}
.banner .num li.on {background-color: #ff6a00;}
.banner .btn {
width: 30px;height: 50px;background-color: #808080;opacity: 0.5; filter:alpha(opacity:0.5); position:absolute;top:50%; margin-top:-25px;
cursor:pointer;
text-align:center;
line-height:50px;
font-size:40px;
color:#fff;
font-family:"宋体";
display:none;
}
.banner .btn_l { left:0px;}
.banner .btn_r { right:0px;}
.banner:hover .btn { display:block;}
</style>
<script type="text/javascript">
$(document).ready(function () {
var size = $(".banner .img li").size();
console.log(size);//计算li的数量
//添加四个li,就是添加圆点
for (var j = 0; j < size-1; j++) {
$(".banner .num").append("<li></li>");
}
//给第一个li添加class on
$(".banner .num li").first().addClass("on");
});
</script>
</head>
<body>
<div class="banner">
<ul class="img">
<li><img src="Adient_00020.jpg" alt=""/></li>
<li><img src="Adient_00018.jpg" alt="" /></li>
<li><img src="Adient_00019.jpg" alt="" /></li>
<li><img src="Adient_00020.jpg" alt="" /></li>
</ul>
<ul class="num">
</ul>
<div class="btn btn_l"><</div>
<div class="btn btn_r">></div>
</div>
</body>
</html>