我正在使用MCustomScrollBar,但页面上有多个滚动条实例。我需要能够分别将元素动态.mCSB_container
附加<li>
到每个滚动条。
这本质上是同一个问题,但接受的答案不起作用,因为它试图使用 id 获取 id attr
,而类没有 id。
<div id="titles" class="scroll-box" style="opacity: 1;">
<h2>Latest Titles</h2>
<ul class="scroll-horizontal mCustomScrollbar _mCS_1">
<div class="mCustomScrollBox mCSB_horizontal" id="mCSB_1" style="position:relative; height:100%; overflow:hidden; max-width:100%;">
<div class="mCSB_container" style="position: relative; left: 0px; width: 2860px;">
<li class="product-car"> My Car</li>
<li class="product-bike"> My Bike </li>
<li class="product-tree"> My Tree </li>
</div>
</div>
</ul>
</div>
<div id="titles" class="scroll-box" style="opacity: 1;">
<h2>Latest Houses</h2>
<ul class="scroll-horizontal mCustomScrollbar _mCS_2">
<div class="mCustomScrollBox mCSB_horizontal" id="mCSB_2" style="position:relative; height:100%; overflow:hidden; max-width:100%;">
<div class="mCSB_container" style="position: relative; left: 0px; width: 2860px;">
<li class="product-house"> My House</li>
<li class="product-boat"> My Boat </li>
<li class="product-tree"> My Tree </li>
</div>
</div>
</ul>
</div>
所以我尝试过使用jQuery children,但无济于事。