1.创建链接 复制代码 代码如下: <BR>var o = document.body; <BR>//创建链接 <BR>function createA(url,text) <BR>{ <BR>var a = document.createElement("a"); <BR>a.href = url; <BR>a.innerHTML = text; <BR>a.style.color = "red"; <BR>o.appendChild(a); <BR>} <BR>createA("http://www.jb51.net/","牛C网"); <BR> 2.创建DIV 复制代码 代码如下: <BR>var o = document.body; <BR>//创建DIV <BR>function createDIV(text) <BR>{ <BR>var div = document.createElement("div"); <BR>div.innerHTML = text; <BR>o.appendChild(div); <BR>} <BR>createDIV("牛C网:http://www.jb51.net/"); <BR> 3.创建表单项 复制代码 代码如下: <BR>var o = document.body; <BR>//创建表单项 <BR>function createInput(sType,sValue) <BR>{ <BR>var input = document.createElement("input"); <BR>input.type = sType; <BR>input.value = sValue; <BR>o.appendChild(input); <BR>} <BR>createInput("button","ooo"); <BR> 4.创建表格 复制代码 代码如下: <BR>var o = document.body; <BR>//创建表格 <BR>function createTable(w,h,r,c) <BR>{ <BR>var table = document.createElement("table"); <BR>var tbody = document.createElement("tbody"); <BR>table.width = w; <BR>table.height = h; <BR>table.border = 1; <BR>for(var i=1;i<=r;i ) <BR>{ <BR>var tr = document.createElement("tr"); <BR>for(var j=1;j<=c;j ) <BR>{ <BR>var td = document.createElement("td"); <BR>td.innerHTML = i "" j; <BR>//td.appendChild(document.createTextNode(i "" j)); <BR>td.style.color = "#FF0000"; <BR>tr.appendChild(td); <BR>} <BR>tbody.appendChild(tr); <BR>} <BR>table.appendChild(tbody); <BR>o.appendChild(table); <BR>} <BR>createTable(270,270,9,9); <BR>