我使用了perfect-scrollbar js插件。滚动条工作正常。但是当我为另一个内容(同一页面)再次添加此滚动条时,它对第二个div
不起作用。如何使用此插件在同一页面中添加多个滚动条?
JS
jQuery(document).ready(function ($) {
"use strict";
$('#Default').perfectScrollbar();
});
CSS
#Default.contentHolder { position:relative; margin:0px auto; margin-top: 20px; padding:0px; width: 285px; height: 450px; overflow: hidden; border: 1px solid #CCC; }
HTML
<div id="Default" class="contentHolder">
/*content goes here. scrollbar works fine here */
</div>
<div id="Default" class="contentHolder">
/*another content goes here. scrollbar does not work here*/
</div>
3条答案
按热度按时间9bfwbjaz1#
对于最新版本,请使用此
https://github.com/utatti/perfect-scrollbar/issues/246#issuecomment-356918832
zpqajqem2#
1.您的HTML无效。不能在多个元素上具有相同的ID。
1.使用类来分配插件。例如:
或者你也可以使用
.each
循环,如果它不工作。例如:hgqdbh6s3#