1

I am using bootstrap to style tables, e.g.,

<table class="table table-striped main">   

but the table that I want to style is actually generated programmatically by another tool that I don't control, and it already comes with its own table class tag:

<table class="foo">

I can include css style sheets though. Is there a way to alias "foo" and "table-striped" to be the same class in my own css?

JRR
  • 6,014
  • 6
  • 39
  • 59
  • 1
    Find `.table-striped {` in the `bootstrap.css` and change it to: `.foo, .table-striped`. – Praveen Kumar Purushothaman Dec 27 '15 at 22:02
  • Or in your own stylesheet simply copy the `.table-striped` rules from Bootstrap and make a copy with the class `.foo` – j08691 Dec 27 '15 at 22:04
  • @j08691 Sorry it's actually multi-class table. – JRR Dec 27 '15 at 22:06
  • use jquery (or vanila js) and find all tables with class `.foo` and add any bootstrap extra css classes you need, that way you dont have to duplicate css code her and there all the time – Nikos M. Dec 27 '15 at 22:08
  • Possible duplicate of [Can we include common css class in another css class?](http://stackoverflow.com/questions/1576147/can-we-include-common-css-class-in-another-css-class) – Lukas Dec 27 '15 at 22:08

1 Answers1

0

Method 1: You can modify your css so that the same effects apply to both classes:

.foo, .table-striped{ some css }

Method 2:

Instead of aliasing them, you can simply perform a search for all elements with class name "foo" and add the class name "table-striped" to them.

var tmp = document.getElementsByClassName("foo");
for(var i=0, j=tmp.length; i<j; i++){
    tmp[i].className += " table-striped";
}

Keep in mind that this is using javascript.