难道是用document.write()来写HTML中的
<table>
<tr>
<td></td>
</tr>
</table>
吗 ?是写在一个document.write()里面,还是写在许多个document.write()里面?
具体应该怎么做呢?
<table>
<tr>
<td></td>
</tr>
</table>
吗 ?是写在一个document.write()里面,还是写在许多个document.write()里面?
具体应该怎么做呢?
解决方案 »
- getElementById 获取label值
- 在同一个窗口中,从别的标签页切换到当前页面时,javascript写的淡入淡出效果在火狐、chrome中出现闪烁的问题
- 有人想了解JQuery、Ext、dojo之类的优缺点,你想知道什么呢?
- fieldset怎样适应各种分辨率下的高度
- JS用的多的大虾们进来,小弟有事请教!
- 关于javascript的小问题
- 标记<a>的Onclick事件没反应
- document.write 输出脚本问题
- javascript如何向另外一个页面提交一个数组?
- 怎样去除Javascript产生的广告条?
- 类似obj.onclick=window.open("http://www.aaa.com")网页跳转(打开新窗口)的方法?
- 大哥大姐进来帮下忙
<script type=...>document.write('<table..........');
document.write('<tr><td..........');
document.write('</td></tr>\
<tr>\
<td>\
内容.....................\
</td>\
</td>');
</script>
第一种方法:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function insRow()
{
var tbl = document.getElementById('myTable');
var row = tbl.insertRow(0);
var cell = row.insertCell(0);
cell.innerHTML="new cell";
}
</script>
</head> <body>
<table id="myTable" border="1">
<tr>
<td>
cell
</td>
</tr>
</table>
<br />
<input type="button" onclick="insRow()" value="Insert row">
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-31j">
<title>Insert title here</title><script type="text/javascript">
function init() {
var table = document.createElement('table');
var tr = table.insertRow(0);
var td = document.createElement('td');
var text = document.createTextNode('12345');
td.appendChild(text);
tr.appendChild(td);
document.body.appendChild(table);
}
</script>
</head>
<body onload="init();">
</body>
</html>
将能用DOM的都用了DOM
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-31j">
<title>Insert title here</title>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript">
function init() {
var row = createElement('DIV'); var cell = createElement('SPAN', null, {
display: 'inline-block',
width: '100px',
height: '30px',
borderStyle: 'solid',
borderWidth: '1px'
});
row.appendChild(cell);
var row1 = createElement('DIV');
var cell2 = createElement('SPAN', null, {
display: 'inline-block',
width: '100px',
height: '30px',
lineHeight: '30px',
borderStyle: 'solid',
borderWidth: '1px',
textAlign: 'center'
});
row1.appendChild(cell2);
createTextNode('TEST', cell2);
document.getElementById('container').appendChild(row);
document.getElementById('container').appendChild(row1);
}
</script>
</head>
<body onload="init();">
<div id="container"></div>
</body>
</html>
test.js
function createElement(tagName, tagProp, tagStyle) {
var element = document.createElement(tagName);
if (tagProp) {
for (var prop in tagProp) {
element[prop] = tagProp[prop];
}
}
if (tagStyle) {
for (var prop in tagStyle) {
element.style[prop] = tagStyle[prop];
}
}
return element;
}function createTextNode(text, parentNode) {
parentNode.appendChild(document.createTextNode(text));
return parentNode;
}
缺点:需要对css有一定了解