我正在使用这个 jQuery 选择下一个列表元素并克隆该类,.slide-title
然后将其附加到另一个类。
$('li:visible').next('.slide-title').clone().appendTo('.feat_next');
这是 HTML 和jsfiddle如果我从.next()
函数中删除选择器,它会克隆下一个列表元素并附加它。那么为什么它找不到.slide-title
类呢?
谢谢
<ul id="slider" style="position: relative;">
<li style="position: absolute; top: 0px; left: 0px; display: block; z-index: 4; opacity: 1;">
<div class="content_left">
<p class="slide-date">July 2, 2012</p>
<h2><a class="slide-title" href="#">3333333333</a></h2>asdfasfasfasdfasdfasdfasdfasfdasfdasfdasfd
<p class="post-byline">by admin</p>
</div>
<div class="img_right"><a href="#"><img src="#"></a>
</div>
</li>
<li style="position: absolute; top: 0px; left: 0px; display: none; z-index: 2; opacity: 0;">
<div class="content_left">
<p class="slide-date">April 1, 2013</p>
<h2><a class="slide-title" href="#">asdfasdfasdf</a></h2>asdfasfasdfasdfasdf
<p class="post-byline">by admin</p>
</div>
<div class="img_right"><a href="#"><img src="#"></a>
</div>
</li>
<li style="position: absolute; top: 0px; left: 0px; display: none; z-index: 1; opacity: 0;">
<div class="content_left">
<p class="slide-date">April 2, 2013</p>
<h2><a class="slide-title" href="#">223234234</a></h2>asdfasfdasfasfasfasdfasdf
<p class="post-byline">by admin</p>
</div>
<div class="img_right"><a href="#"><img src="#"></a>
</div>
</li>
</ul>
<div class="feat_next"><a href="#"></a></div>
<div class="feat_prev"><a href="#"></a></div>