简体   繁体   中英

jquery <span> inside next()

im trying to get this so that it rotates through LI's, and will fadein the SPAN within that LI after and before the next slide.

heres my code:

        var current = ($('.slider ul li.current'));
    var currentspan = ($('.slider ul li.current span'));
    var next = (current.next().length) ? current.next() : $('.slider ul li:first');
    var nextspan = (current.next('span').length) ? current.next('span') : $('.slider ul li:first span');

The problem is my nextspan variable has to be wrong. All i want to do is grab the SPAN inside the NEXT LI. as you can see the next variable gets set fine - so how do i get the span inside that next variable?

next() only gets the next sibling. So as the span is a child of the next li you'll have to do something like this:

current.next().find('span')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM