jQuery Perfect Scroll - 将滚动条设置为容器的底部

Jas*_*ndo 4 javascript jquery jquery-plugins

我刚刚安装了完美的滚动,jQuery插件,它工作得很好,但我找不到一个参数来启动div底部的内容.我想要向上滚动页面加载,而不是向下滚动.

通常使用jQuery我会这样做:

$(nav_message_list).prop({ scrollTop: $(nav_message_list).prop("scrollHeight")});
Run Code Online (Sandbox Code Playgroud)

但这似乎没有效果.

当前代码:

$(".chat_person").click(function ()
                         {
                          if (!$(".chat_content_wrap").is(":visible"))
                           {  
                            $(".chat_content_wrap").fadeIn(300, function ()   
                                                                 {
                                                                  $('#message_list').perfectScrollbar('update');
                                                                  $(nav_message_list).prop({ scrollTop: $(nav_message_list).prop("scrollHeight")});
                                                                 });
                           }
                          });

$("#message_list").perfectScrollbar();
Run Code Online (Sandbox Code Playgroud)

Tra*_*rie 15

我之前没有使用过该插件,但是基于https://github.com/noraesae/perfect-scrollbar上的文档

您应该需要的代码是:

$("#message_list").scrollTop( $( "#message_list" ).prop( "scrollHeight" ) );
$("#message_list").perfectScrollbar('update');
Run Code Online (Sandbox Code Playgroud)

$ selectors可能是错的,因为我看不到你的HTML代码.