本文實(shí)例講述了JS實(shí)現(xiàn)向表格行添加新單元格的方法。分享給大家供大家參考。具體如下:
下面的JS代碼可以想表格中指定id的行插入新的單元格
<!DOCTYPE html><html><head><script>function insCell(){var x=document.getElementById('tr1').insertCell(0);x.innerHTML="The famous";}</script></head><body><table border="1"><tr id="tr1"><td>Peter</td><td>Griffin</td></tr></table><br><input type="button" onclick="insCell()" value="Insert cell"></body></html>希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注