Jump to content

jquery selecting last li in the first set of ul li?


shortysbest

Recommended Posts

I have a comment page, i use the id from li to load more comments.

the structure of my comments are:

 

<ul class='stream'>

<li id='1'>

  <ul class='post-controls'

  <li id='toggle1'></ul>

  </ul>

</li>

 

<li id='2'>

  <ul class='post-controls'

  <li id='toggle2'></ul>

  </ul>

</li>

</ul>

 

That's basically how it would look for two comments.

Now here's the issue, I'm using jquery to select the last comment on the page so I can get the id of the last loaded comment, to load from there on to the next set of comments. it's an auto loading type of thing. The problem is it's selecting the 2nd set of li id (ul.stream li#2 ul.post-controls li#toggle2) instead of (ul.stream li#2)

 

this is the code:

 

var lastID = $(".stream li:last").attr('id');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.