从div中删除slimscroll

And*_*tri 12 jquery scroll slimscroll

我有一个div,为了让它更漂亮,我在该div上使用了SlimScroll jQuery插件

$('#scrollable').slimscroll({
   color: '#900',
   size: '8px',
   width: '300px',
   height: '500px'
});
Run Code Online (Sandbox Code Playgroud)

现在有一个时刻,我希望这个div不再具有此属性(但是要使用浏览器默认滚动条).我怎样才能删除slimscroll

ink*_*ink 16

$("#scrollable").slimScroll({destroy: true});
Run Code Online (Sandbox Code Playgroud)


And*_*tri 6

我做了这个功能,在我的情况下效果很好

function destroySlimscroll(objectId) { 
   $("#"+objectId).parent().replaceWith($("#"+objectId)); 
}
Run Code Online (Sandbox Code Playgroud)


Dan*_*chi 6

我这样做了,它比我看到的任何其他解决方案都更好.

$(".slimScrollBar,.slimScrollRail").remove();
$(".slimScrollDiv").contents().unwrap();
Run Code Online (Sandbox Code Playgroud)