+ 1
How can I make a table of 52 rows and column in html without writing codes for each of them.
6 Respuestas
+ 2
HTML:
————————————————
<div id="test"></div>
————————————————
JS (tarr with your 52 elements):
————————————————
let row, test = document.querySelector('#test'), tarr = ["ja1","ja2","ja3","ja4"];
for(let k=0;k<52;k++){
row = creTr(4,"th",tarr);
test.appendChild(row);
}
function creTr(nc,typ,item){
let type, txt;
let tr = document.createElement("tr");
for(let i=0;i<nc;i++){
type = document.createElement(typ);
txt = document.createTextNode(item[i]);
type.appendChild(txt);
tr.appendChild(type);
}
return tr;
}
+ 1
Type <tr> inside the <table> for 52 times and type <th> for 52 time inside each <th>.
+ 1
You can copy paste the first row of 52 columns to make you work simple
+ 1
https://code.sololearn.com/WUHR9I6JXs77/?ref=app check this code. I have implemented something similar there.
0
That's what I running away from. I just want a code that will bring it out once