.first() 无法过滤我的第一个类



我不知道我的jquery出了什么问题,我正在尝试做一个内容滑块,但由于某种原因,我的.first()无法过滤我的第一个类。

我所说的的一个例子

jQuery

 1. $('.textinside').first().addClass('active');

CSS

.active{
   display: block;
}
.textinside{
   color: blue;
   font-size: 19px;
   background-color: black;
   position: absolute;
   display: none;
}

html

<div class="container">
<div class="textinside">text1</div>
<div class="textinside">text2</div>
<div class="textinside">text3</div>
</div>

交换CSS文件中的两个类。第二个覆盖第一个。所以使用:

.textinside{
   color: blue;
   font-size: 19px;
   background-color: black;
   position: absolute;
   display: none;
}
.active {
   display: block;
}

它会起作用的。演示:http://jsfiddle.net/bcexLgvd/

最新更新