我使用jQuery 自定义内容滚动器创建自定义内容滑块,我需要为其拖动器设置样式。例如,如果我将它拖到一半 - 在红色(任何颜色)轨迹后面。反之亦然。感谢您的任何建议)
例子
(function($){
$(window).load(function(){
$("#content-1").mCustomScrollbar({
axis:"x",
advanced:{
autoExpandHorizontalScroll:true
}
});
var i=1,
imgs=["http://placehold.it/500x300.jpg","http://placehold.it/500x300","http://placehold.it/500x300","http://placehold.it/500x300","http://placehold.it/500x300","http://placehold.it/500x300","http://placehold.it/500x300"];
$("a[rel='add-content']").click(function(e){
e.preventDefault();
var markup="<li id='img-"+i+"-container'><img src='"+imgs[i]+"' /></li>";
$(".content .mCSB_container ul").append(markup);
if(i<imgs.length-1){
i++
}else{
i=0;
}
});
$("a[rel='remove-content']").click(function(e){
e.preventDefault();
if($(".content .mCSB_container ul li").length<4){return;}
i--
if(i<0){i=imgs.length-1;}
$("#img-"+i+"-container").remove();
});
});
})(jQuery);