Overwrite button class in a colvis button

Overwrite button class in a colvis button

ZubyZuby Posts: 14Questions: 4Answers: 0
edited November 2023 in Free community support

I am using bootstrap5 datatables set up.
I have a button for column visibility. The button comes already styles with btn-secondary.
I have done this
buttons: [
{
extend:'colvis',
text:'Show/Hide',
className:'btn-primary'
}
],
I want the button to come in the btn-primary class which is the color for my application but it doesn't change. The btn-secondary prevails. The colour changes when i change the className to bg-primary but that isn't quite what I want. How can I either overwrite or remove the btn-secondary class so my btn-primary color canwork/show

Answers

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    See if this thread helps.

    Kevin

  • ZubyZuby Posts: 14Questions: 4Answers: 0

    Oh thanks Kthorngren, The problems look similar. I'm using vanilla Js and not jquery with my datatables. I guess I would need to figure out how to do the solution I saw in vanilla Js.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
     $(".btnInsert").removeClass("dt-button");
    

    without jQuery is:

    document.querySelectorAll('.btnInsert').forEach( el => el.classList.remove('dt-button') );
    

    or if there is only one element (and you are certain there is a matching element):

    document.querySelector('.btnInsert').classList.remove('dt-button');
    

    Allan

Sign In or Register to comment.