eq even odd last not 选择器
@{
ViewBag.Title = "Index";
}
<script src="../../Scripts/jquery-1.7.1.min.js"></script>
<style type="text/css">
.fa {
border:1px solid green;
height:auto;
width:80px;
}
.fa div:nth-child(odd){
border:1px solid red;
height:20px;
width:70px;
margin:2px
}
.fa div:nth-child(even){
border:1px solid blue;
height:20px;
width:70px;
}
</style>
<html>
<body>
<div class="fa">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
</div>
<div class="last">last</div>
</body>
</html>
<script type="text/javascript">
var even = $(".fa div:even").css("border");
var odd = $(".fa div:odd").css("border");
var first1 = $("div:first").attr("class");
var first2 = $("div").first().attr("class");
var last1 = $("div:last").attr("class");
var last2 = $("div").last().attr("class");
var not1 = $("div:not(.last)").length;
var not2 = $("div").not(".last").length;
var eq1 = $("div:eq(2)").html();//2
var eq2 = $("div").eq(2).html();//2
</script>
浙公网安备 33010602011771号