steve
steve

Reputation: 664

how to append class for nicescroll

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

Answers (6)

Deo
Deo

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

besabestin
besabestin

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

Awesome
Awesome

Reputation: 1

You can add class with jquery:

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

Upvotes: 0

Laguna Web Design
Laguna Web Design

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

Milind Anantwar
Milind Anantwar

Reputation: 82241

You can use:

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

See Docs

Upvotes: 0

rajesh kakawat
rajesh kakawat

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

Related Questions