1

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.

pbaris
  • 4,525
  • 5
  • 37
  • 61
steve
  • 664
  • 4
  • 16
  • 42
  • I don't think CSS has those properties, those are only paramenters given for the `niceScroll method` – Spokey Feb 20 '14 at 09:39

6 Answers6

2

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');
besabestin
  • 482
  • 8
  • 26
0

you can't do that but you may try

var options = {
    cursorwidth: '8px',
    cursorborder: 'none',
    cursorborderradius:'0px',
    cursorcolor:"#39CCDB"
};
$("#Total").niceScroll(options);
rajesh kakawat
  • 10,826
  • 1
  • 21
  • 40
0

You can use:

$("#Total").niceScroll({cursorcolor:"#39CCDB",cursorwidth:"8px",cursorborderradius:"0px",cursorborder: "none"});

See Docs

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

try below code will work for

var scrollbar =  $("#Total").niceScroll({});
$("#Total").addClass("scroll");

.scroll {
    cursorwidth: '8px',
    cursorborder: 'none',
    cursorborderradius:'0px',
    cursorcolor:"#39CCDB"
}
pbaris
  • 4,525
  • 5
  • 37
  • 61
Deo
  • 82
  • 5
0

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" */
}
0

You can add class with jquery:

var $scrollbar =  $(selector).niceScroll({});
$scrollbar.cursor.parent().addClass('nicescroll-cursor-parent');
Awesome
  • 1
  • 1