Reputation: 2775
I have an element in my page and I am using a Jquery Plugin to scroll to the last <li>
in the page whenever a new <li>
is added but it is not working. The plugin link is scrollTo Plugin
<ol class"chat">
<li>chat 1</li>
<li>chat 2</li>
<li>chat 3</li>
<li>chat 4</li>
<li>chat 5</li>
<li>chat 6</li>
</ol>
my code is: $('.chat').scrollTo('*:last', 0);
Upvotes: 0
Views: 350
Reputation: 2775
I was able to solve the problem using the code below without the plugin.
$("html, body").animate({ scrollTop: $(document).height()-$(window).height() },1000);
Upvotes: 0
Reputation: 18873
Instead of
$('.chat').scrollTo('*:last', 0);
Try(You want last li
so instead of *
use li
)
$('.chat').scrollTo('li:last', 0);
OR (I don't think there is any need of 0),So try this :-
$('.chat').scrollTo('li:last');
Upvotes: 2