How this style can be added in javascript?
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
padding: 8px;
line-height: 1.42857143;
vertical-align: top;
border-top: 1px solid #ddd;
border-top-width: 1px;
border-top-style: solid;
border-top-color: rgb(221, 221, 221);
}
CodePudding user response:
Put all that in a css
file, then inject it like so (edit the path-to/your-css-file.css
bit):
let link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = 'path-to/your-css-file.css';
document.head.appendChild(link);
CodePudding user response:
You can use classList first, create a class includes this styles. Then, use this on JavaScript:
document.querySelector("example").classList.add("className");