I'm trying to get the next slide element attr href
after the active current one.
<ul class="nav">
<li class="active"><a href="#slide01"></a></li>
<li><a href="#slide02"></a></li>
<li><a href="#slide03"></a></li>
<li><a href="#slide04"></a></li>
</ul>
To get the current one I do
slideActive = $('.nav li.active a').attr('href')
which is good it gives #slide02
, however I'm not sure how to get the href
of the previous or next li
elements.
Try this:
1.for selecting the href of the next element
$('.nav li.active').next('li').find('a').attr('href')
2.for selecting the href of the previous element
$('.nav li.active').prev('li').find('a').attr('href')
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.