【发布时间】:2014-12-22 05:45:15
【问题描述】:
我不知道为什么当我使用 jQuery 的 .css() 函数时它会返回:
Uncaught TypeError: undefined is not a function
我的代码是这样的:
HTML:
<div class="photo1 sliderPhoto">d</div>
<div class="photo2 sliderPhoto">d</div>
<div class="photo3 sliderPhoto">d</div>
<div class="photo4 sliderPhoto">d</div>
CSS:
.sliderPhoto{
position: absolute;
top: 0px;
left: 0px;
background-position: center center;
background-size: cover;
width: 100%;
height: 100%;
}
.photo1{
background-image: url('../photos/ph1.jpg');
z-index: 6;
}
.photo2{
background-image: url('../photos/ph2.jpg');
z-index: 6;
display: none;
}
.photo3{
background-image: url('../photos/ph3.jpg');
z-index: 6;
display: none;
}
.photo4{
background-image: url('../photos/ph4.jpg');
z-index: 6;
display: none;
}
$(document).ready 上的 JQuery:
$photos = [$(".photo1")[0], $(".photo2")[0], $(".photo3")[0], $(".photo4")[0]];
$photos[0].css("z-index");
当我输入这个 jQuery 代码时它不起作用:( 但这个 $photos[0] 返回我需要的确切 div。
【问题讨论】:
标签: javascript jquery html css