javascript - getting wrong data value from last li in ul -


trying data-id value last li in ul. returns empty.

js :

var ss_id = $('#lightslider .slides').last().data('id'); 

ul/li structure :

the same li structure repeats different data.

<ul id="lightslider" class="gallery list-unstyled clearfix lightslider csslide" style="width: 1124px;">     <li class="slide active" title="(window has no title) " data-thumb="/showimage.php?show=test1.jpg" data-id="30" style="width: 1094px; float: left; margin-right: 30px;">         <img class="img-responsive" title="(window has no title) " src="/showimage.php?show=test1.jpg">         <div style="border-top:1px #dddddd solid; padding:0 15px 15px 15px; background:#f5f5f5;">             <h4><b>wed, 06/25/14 @ 4:58:24 utc</b></h4>             <ul class="list-unstyled">                 <li><b>1 :</b> test</li>                 <li><b>2 :</b> test</li>                 <li><b>3 :</b> test</li>             </ul>         </div>     </li> </ul> 

i think there simple mistake: try .slide class instead of .slides

var ss_id = $('#lightslider .slide').last().data('id'); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -