---
title: "js操作table"
author: "xchyou"
date: "2012-08-30T18:00:30Z"
tags: ["JavaScript html table"]
categories: ["Web前端"]
slug: "js-table"
draft: false
lastmod: "2012-08-30T18:02:46Z"
id: 1668164
url: "https://xchyou.iteye.com/blog/1668164"
---

var stable = document.getElementById('stable');

 

添加\\删除行

stable.insertRow();

stable.deleteRow(rowIndex);

 

添加\\删除列

stable.rows\[rowIndex].insertCell();

stable.rows\[rowIndex].deleteCell(cellIndex);

 

给列添加内容

stable.rows\[rowIndex].cells\[cellIndex].innerText = ;

stable.rows\[rowIndex].cells\[cellIndex].innerHtml =;