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');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.