document.getElementTagName;
document.getElementsByClassName
document.getElementById
document.querySelector
document.querySelectorAll
2.操作元素
通过循环来生成tr和td
<div class="exchange" id="box">1 </div>
var trStr="";
for(var i=0;i<3;i++){
var tdStr = "";
for (var j = 0; j < 3; j++) {
tdStr += "<td>td里内容</td>";
if(i%2==0){
trStr+="<tr style='background:blue'>"+tdStr+"</tr>";
}else{
trStr+="<tr>"+tdStr+"</tr>";
var tableStr="<table border='1'>"+trStr+"</table>";
var divEle = document.querySelector(".exchange");
divEle.innerHTML=tableStr;
3创建dom元素
document.createElement("p")
p.innerHTML = "我是p内容";
var liEle=document.createElement("li")
var pEle=document.createElement("p")
liEle.appendChild(pEle);
4用元素创建表格
var tableEle = document.createElement("table") ;
for(var i=0;i<3;i++){
var trEle = document.createElement("tr");
if(i%2==0){
trEle.style.backgroundColor = "blue";
for(var j=0;j<3;j++){
var tdEle = document.createElement("td");
td1.innerText = "内容";
trEle.appendChild(tdEle);
tableEle.appendChild(trEle);
console.log(tableEle);
document.body.appendChild(tableEle);
sunShine