用 table 的 insertRow() 和 insertCell() 增加表格行时,所在 div 怎么会跳到页面下方去呢? 不要overflow: auto;这一句就是好的了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <button onclick="load()">加载数据</button> <div style="width:600;height:370;overflow: auto;border:1px solid #666; position:relative; display:table-cell; text-align:center; vertical-align:middle"> <table width="100%" id="dataTable" align="center" border=1 style="border-collapse: collapse"> <tr style="font-weight:bold"> <td>编号</td> </tr> <tr style="font-weight:bold"> <td>编号</td> </tr> </table> </div><script> function load(){ for(var i=0;i<100;i++){ var newRow = document.getElementById('dataTable').insertRow(); newCell = newRow.insertCell(); newCell.innerText = '编号'; } }</script> 好像是因为tr,td是块元素,把table加个float:left也可以解决 jquery mobile 加载两次 js 继承带来的苦果! 请帮忙看下,js 跨域 访问 window.opener问题 弹出窗口的问题 onkeypress问题 关于模态对话框的奇怪的问题 怎样利用Javascript对隐藏对象赋值啊? 关于 angular js 捕获键盘事件问题 发了两次了 ,真的没有高手么???????????? 问个比较基础的问题 用jsp实现身份验证登录的代码
<button onclick="load()">加载数据</button> <div style="width:600;height:370;overflow: auto;border:1px solid #666;
position:relative;
display:table-cell;
text-align:center;
vertical-align:middle">
<table width="100%" id="dataTable" align="center" border=1 style="border-collapse: collapse">
<tr style="font-weight:bold">
<td>编号</td>
</tr>
<tr style="font-weight:bold">
<td>编号</td>
</tr>
</table>
</div><script>
function load(){
for(var i=0;i<100;i++){
var newRow = document.getElementById('dataTable').insertRow(); newCell = newRow.insertCell();
newCell.innerText = '编号';
}
}
</script>