shortysbest Posted May 22, 2011 Share Posted May 22, 2011 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'); Quote Link to comment Share on other sites More sharing options...
JustLikeIcarus Posted May 26, 2011 Share Posted May 26, 2011 Change it to this to keep it from looking inside the nested elements. var lastID = $(".stream > li:last").attr('id'); Pretty much the same, just added a ">" Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted May 26, 2011 Share Posted May 26, 2011 apart from it being jquery, classes and id's may not start with a number. In other words start of with a-z Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.