87,904
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<textarea cols="100" rows="20" id="code"></textarea>
<div id="container">aaaaa</div>
<script type="text/javascript">
function domTable(){
var rowCount = 10;
var cellCount = 10;
var tb = document.createElement("table");
tb.border = 1;
tb.cellspacing = 2;
tb.cellpadding = 2;
for(var i=0; i<rowCount; i++){
var tr = document.createElement("tr");
for(var j=0; j<rowCount; j++){
var td = document.createElement("td");
td.innerHTML = i + "-" + j;
tr.appendChild(td);
}
tb.appendChild(tr);
}
document.getElementById("container").appendChild(tb);
if(tb.outerHTML)document.getElementById("code").value = tb.outerHTML;
}
function radioGroup(){
var count = 10;
var checkedIndex = 4;
var groupName = "test";
var frag = document.createDocumentFragment();
for(var i=0; i<count; i++){
var r = document.createElement("input");
r.type = "radio";
r.name = groupName;
r.id = groupName + "_" + i;
var label = document.createElement("label");
label.innerHTML = r.id;
label['for'] = r.id;
if(i == checkedIndex) r.checked = true;
frag.appendChild(r);
frag.appendChild(label);
}
document.getElementById("container").appendChild(frag);
}
domTable();
radioGroup();
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<textarea cols="100" rows="20" id="code"></textarea>
<div id="container">aaaaa</div>
<script type="text/javascript">
function domTable(){
var rowCount = 10;
var cellCount = 10;
var tb = document.createElement("table");
var tbody_node=document.createElement("tbody");
tb.border = 1;
tb.cellspacing = 2;
tb.cellpadding = 2;
for(var i=0; i<rowCount; i++){
var tr = document.createElement("tr");
for(var j=0; j<rowCount; j++){
var td = document.createElement("td");
td.innerHTML = i + "-" + j;
tr.appendChild(td);
}
tbody_node.appendChild(tr);
}
tb.appendChild(tbody_node);
document.getElementById("container").appendChild(tb);
if(tb.outerHTML)document.getElementById("code").value = tb.outerHTML;
}
function radioGroup(){
var count = 10;
var checkedIndex = 4;
var groupName = "test";
var frag = document.createDocumentFragment();
for(var i=0; i<count; i++){
var r
if(document.all){
r= document.createElement("<input name='testRadioName'>"); //这里
r.type = "radio";
}else{
r= document.createElement("input"); //这里
r.type = "radio";
r.name="text"
}
// r.name = "test"; //这个方法好象不行
r.id = groupName + "_" + i;
var label = document.createElement("label");
label.innerHTML = r.id;
label['for'] = r.id;
if(i == checkedIndex) r.checked = true;
frag.appendChild(r);
frag.appendChild(label);
}
document.getElementById("container").appendChild(frag);
}
domTable();
radioGroup();
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<textarea cols="100" rows="20" id="code"></textarea>
<div id="container">aaaaa</div>
<script type="text/javascript">
function domTable(){
var rowCount = 10;
var cellCount = 10;
var tb = document.createElement("table");
var tbody_node=document.createElement("tbody");
tb.border = 1;
tb.cellspacing = 2;
tb.cellpadding = 2;
for(var i=0; i<rowCount; i++){
var tr = document.createElement("tr");
for(var j=0; j<rowCount; j++){
var td = document.createElement("td");
td.innerHTML = i + "-" + j;
tr.appendChild(td);
}
tbody_node.appendChild(tr);
}
tb.appendChild(tbody_node);
document.getElementById("container").appendChild(tb);
if(tb.outerHTML)document.getElementById("code").value = tb.outerHTML;
}
function radioGroup(){
var count = 10;
var checkedIndex = 4;
var groupName = "test";
var frag = document.createDocumentFragment();
for(var i=0; i<count; i++){
var r = document.createElement("<input type='radio' name='test'/>"); //这里
//r.type = "radio";
//r.name = groupName; //这个方法好象不行
r.id = groupName + "_" + i;
var label = document.createElement("label");
label.innerHTML = r.id;
label['for'] = r.id;
if(i == checkedIndex) r.checked = true;
frag.appendChild(r);
frag.appendChild(label);
}
document.getElementById("container").appendChild(frag);
}
domTable();
radioGroup();
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<textarea cols="100" rows="20" id="code"></textarea>
<div id="container">aaaaa</div>
<script type="text/javascript">
function domTable(){
var rowCount = 10;
var cellCount = 10;
var tb = document.createElement("table");
var tbody_node=document.createElement("tbody");
tb.border = 1;
tb.cellspacing = 2;
tb.cellpadding = 2;
for(var i=0; i<rowCount; i++){
var tr = document.createElement("tr");
for(var j=0; j<rowCount; j++){
var td = document.createElement("td");
td.innerHTML = i + "-" + j;
tr.appendChild(td);
}
tbody_node.appendChild(tr);
}
tb.appendChild(tbody_node);
document.getElementById("container").appendChild(tb);
if(tb.outerHTML)document.getElementById("code").value = tb.outerHTML;
}
function radioGroup(){
var count = 10;
var checkedIndex = 4;
var groupName = "test";
var frag = document.createDocumentFragment();
for(var i=0; i<count; i++){
var r = document.createElement("input");
r.type = "radio";
r.name = groupName;
r.id = groupName + "_" + i;
var label = document.createElement("label");
label.innerHTML = r.id;
label['for'] = r.id;
if(i == checkedIndex) r.checked = true;
frag.appendChild(r);
frag.appendChild(label);
}
document.getElementById("container").appendChild(frag);
}
domTable();
radioGroup();
</script>
</body>
</html>