Reputation: 664
I am using nicescroll in my application. I have dedined like
$("#Total").niceScroll({
cursorwidth: '8px',
cursorborder: 'none',
cursorborderradius:'0px',
cursorcolor:"#39CCDB"
});
but I don't want to give the styles as above. I want to apply these using a class.For that I have implemented like
.scroll {
cursorwidth: '8px',
cursorborder: 'none',
cursorborderradius:'0px',
cursorcolor:"#39CCDB"
}
and
var scrollbar = $("#Total").niceScroll({});
scrollbar.addClass("scroll");
but is not working,tell me how to apply stylings with a class for nicescroll.
Upvotes: 1
Views: 2249
Reputation: 82
try below code will work for
var scrollbar = $("#Total").niceScroll({});
$("#Total").addClass("scroll");
.scroll {
cursorwidth: '8px',
cursorborder: 'none',
cursorborderradius:'0px',
cursorcolor:"#39CCDB"
}
Upvotes: 0
Reputation: 492
When facing problems of the kind you can print the whole object in inspector and see what you can use (using console.log(nice)
). So here is my solution
var div = niceScroll({ ... });
var nice = div.getNiceScroll();
$(nice)[0].rail.addClass('class-for-vertical');
$(nice)[0].rail.addClass('class-for-horizontal');
Upvotes: 2
Reputation: 1
You can add class with jquery:
var $scrollbar = $(selector).niceScroll({});
$scrollbar.cursor.parent().addClass('nicescroll-cursor-parent');
Upvotes: 0
Reputation: 332
JS:
$('.custom_scrollbar').each(function(i){
// ...
$(this).niceScroll({ ... });
// ...
$('.nicescroll-rails').eq(i).addClass('your_class_name');
// ...
});
CSS:
.nicescroll-rails.your_class_name div{
background-color:red !important; /* for cursorcolor:"red" */
}
Upvotes: 0
Reputation: 82241
You can use:
$("#Total").niceScroll({cursorcolor:"#39CCDB",cursorwidth:"8px",cursorborderradius:"0px",cursorborder: "none"});
Upvotes: 0
Reputation: 10896
you can't do that but you may try
var options = {
cursorwidth: '8px',
cursorborder: 'none',
cursorborderradius:'0px',
cursorcolor:"#39CCDB"
};
$("#Total").niceScroll(options);
Upvotes: 0