이것이 목록의 마지막 요소인지 여부를 감지하려고합니다. 이 코드는 작동하지 않았습니다. 어떤 것?JQuery 다루기 : 마지막 선택자
if((visel).is($('#twitnews li:last'))) {
var nextel = $('#twitnews li').first();
}
else {
var nextel = $(visel).next();
}
HTML : 당신이 사용하는 경우
<div id="twitnews" style="padding-left:20px; line-height:20px; float:left;">
<li>
Rawwwwrrrr! (@ Great Life Golf & Fitness- Berkshire) http://4sq.com/kCoZKV
</li>
<li>
Swinley Forest Golf Club, Coronation Road, Ascot, Berkshire - Golf Courses http://t.co/fuoN2LW via @AddThis
</li>
<li>
Had to resort to biking indoors tonight. (@ Great Life Golf & Fitness- Berkshire) http://4sq.com/jhbqK2
</li>
<li>
In my golf course review of The Berkshire Blue course I found this to be a great day out, the course is fantastic... http://fb.me/AYkQDseI
</li>
<li>
I'm at Berkshire Hills Golf Club http://4sq.com/kUAPK2
</li>
<li>
Played Berkshire Valley GC in Morris County NJ. Course was really nice. Pics and video review of the course. http://bit.ly/mAjRcz
</li>
<li>
Review for: The Berkshire Golf Club Blue Course. Great course http://bit.ly/hUqV8e
</li>
<li>
A group of four friends from West Berkshire are getting ready to tee off for a charity golf challenge http://bit.ly/l1IWD6
</li>
<li>
I'm at Great Life Golf & Fitness- Berkshire (3720 SW 45th St., at Stone Ave., Topeka) http://4sq.com/jbOX6g
</li>
<li>
Berkshire golf club, hang your head in shame with the state those greens were in! Worst greens i have putted on EVER! #horrific
</li></div>
<script type="text/javascript">
$('#twitnews li').hide();
$('#twitnews li').first().fadeIn(300, function fade(){
var visel = $('#twitnews li:visible');
if($(visel).is($('#twitnews li:last'))) {
var nextel = $('#twitnews li').first();
}
else {
var nextel = $(visel).next();
}
$(visel).delay(3000).fadeOut(300, function(){
$(nextel).fadeIn(300, function(){fade()});
});
});
</script>
당신이 당신의 HTML 여기에 붙여 넣을 수 있습니다 : 당신이 뭔가를 할 필요가? –
이제 질문을 완료 –
'$ ('twitnews li ')'값을 파이어 버그에서 확인하십시오. 반환하는 요소 수를 확인하십시오 –