第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用 JavaScript 在 div 中創(chuàng)建表格

使用 JavaScript 在 div 中創(chuàng)建表格

躍然一笑 2023-12-04 14:38:02
超文本標(biāo)記語(yǔ)言       <h1>Javascript Playground</h1>        <div id="first"></div>        <div id="second"></div>    </body>我需要在 div 中插入一個(gè)包含此信息的表格,包括代碼、標(biāo)題和產(chǎn)品列,而不接觸 HTML(僅使用 JavaScript)let units = [    {        'code': 'COMP2110',        'title': 'Web Technology',         'offering': 'S1'    },      {        'code': 'COMP2010',        'title': 'Algorithms and Data Structures',         'offering': 'S1'    },]
查看完整描述

1 回答

?
慕田峪7331174

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超13個(gè)贊

也許你可以像下面這樣開(kāi)始:


let units = [{'code': 'COMP2110', 'title': 'Web Technology', 'offering': 'S1'}, {'code': 'COMP2010', 'title': 'Algorithms and Data Structures', 'offering': 'S1' } ];


// find your div first

const div = document.getElementById('first');


// building the HTML for the div

let html = `<table>

     <thead>

         <tr>

           ${Object.keys(units[0]).map(e => `<th>${e}</th>`).join('')}

         </tr>

     </thead>`


html += `<tbody>`;

units.forEach(e => html += `<tr>

      ${Object.values(e).map(v => `<td>${v}</td>`).join('')}

</tr>`);


html += `</tbody></table>`;


// adding HTML to your div

div.innerHTML = html;

table, th, td {

  border: 1px solid black;

}

<h1>Javascript Playground</h1>


<div id="first"></div>

<div id="second"></div>


查看完整回答
反對(duì) 回復(fù) 2023-12-04
  • 1 回答
  • 0 關(guān)注
  • 200 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)