table的自动增加
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
margin: 0;
padding: 0;
font-size: 14px;
-webkit-user-select: none;
} .box {
margin: 10px auto;
padding: 20px;
width: 100%;
border: 1px solid darkcyan; border-radius: 5px;
box-shadow: 3px 3px 10px 0 grey;
} .box table {
border-collapse: collapse;/*去除单元格个单元格之间的空隙*/
border:1px solid #000;
} .box thead tr {
border:1px solid #000;
height: 20px;
line-height: 20px;
text-align: center;
/*background: cornflowerblue;*/
} .box thead tr th {
width: 100px;
color: #000;
border-bottom: 1px solid #cccccc;
padding: 10px; } .box thead tr th {
cursor: pointer; } .box tbody tr {
height: 30px;
line-height: 30px;
text-align: center;
} .box tbody tr td {
border:1px solid #000;
width: 100px;
} /*.box tbody tr {*/
/*background: lightblue;*/
/*}*/
input{
width:100px;
} </style>
</head>
<body>
<div class="box">
<input type="button" value="添加型号" onclick="insertRow3()">
<input type="button" value="添加参数" onclick="addRow()">
<input type="button" value="添加标题" onclick="insertRow()">
<table id="table_info3">
<tr>
<td id="td0"></td>
</tr>
</table>
</div>
</body>
</html>
<script src="jquery-3.1.1.min.js"></script>
<script>
//添加型号
function insertRow3() {
//获取table对象
var table = document.getElementById("table_info3");
//找到要添加button的td,这里以表格第一行第一列为例子
for(var i = 0; i<table.rows.length; i++){
var trid = document.getElementById("td"+i);
//alert(trid.colSpan);
if(trid.colSpan!==1){
trid.colSpan = trid.colSpan + 1;
}else{
var oTd2 = table.rows[i].insertCell();
oTd2.innerHTML = "<input type='text'>";
//alert(table.rows[i]);
} }
}
//添加参数
function addRow() {
var table = document.getElementById("table_info3");
id="td"+table.rows.length;
var newTR = document.getElementById("table_info3").insertRow(document.getElementById("table_info3").rows.length);
for(var i=0;i<table.rows[0].cells.length;i++){ var newNameTD = newTR.insertCell();
}
newNameTD.setAttribute('id',id); //alert(newNameTD.getAttribute('id'));
//newNameTD.innerHTML = "<input type='text'/>";
// var newNameTD = newTR.insertCell();
// newNameTD.innerHTML = "<input name='LastName' id='LastName' type='text' />";
}
//添加标题
function insertRow() {
var table = document.getElementById("table_info3");
id="td"+table.rows.length;
var oTable = document.getElementById("table_info3");
var oTr = oTable.insertRow();
var oTd = oTr.insertCell();
oTd.setAttribute('id',id);
oTd.innerHTML = "<input type='text'/>";
oTd.setAttribute('colspan',table.rows[0].cells.length); }
function add(a){
a=Number(a)+1;
return a;
}
</script>
table的自动增加的更多相关文章
- 安卓使用SQlite3数据库无法id主键无法自动增加?不是的。
安卓使用SQlite3数据库无法id主键无法自动增加?不是的. 要这样写:id integer primary key ,要写integer而不是int所以会报错! http://blog.csdn. ...
- MySQL每天自动增加分区
有一个表tb_3a_huandan_detail,每天有300W左右的数据.查询太慢了,网上了解了一下,可以做表分区.由于数据较大,所以决定做定时任务每天执行存过自动进行分区. 1.在进行自动增加分区 ...
- 使用JDBC获取能自动增加的主键
本篇讲述如何使用JDBC获取能自动增加的主键的值.有时候我们在向数据库插入数据时希望能返回主键的值,而不是通过查询的方式.一般来说,在多表相互关联主键约束,也就是说别的表的外键约束是该表的主键,那么在 ...
- jQuery表格自动增加
<!DOCTYPE html> <html dir="ltr" lang="zh-CN"> <head> <meta ...
- 【原】设置iOS项目BuildVersion自动增加
一.概念阐述:Build与Version的区别 在iOS中有两种“版本号”,也就是所谓的version号与build号,如下图所示: 我们用最简洁的语言来区分这两个版本号的区别以及用途如下: Vers ...
- C#获取程序集自动增加的版本号和编译时间
1. 首先找到文件AssemblyInfo.cs, 路径如下: 2. 修改版本的格式,修改后,程序每次编译,程序集的版本号都会自增. 修改前: [assembly: AssemblyVersion(& ...
- 设置iOS项目BuildVersion自动增加-备用
一.概念阐述:Build与Version的区别 在iOS中有两种“版本号”,也就是所谓的version号与build号,如下图所示: 我们用最简洁的语言来区分这两个版本号的区别以及用途如下: Vers ...
- 如何自动增加和从代码读取Xcode项目的版本号
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) Xcode项目和版本号相关的有2个地方Version和Buil ...
- 关于发件人地址会自动增加BATV及prvs的问题处理方法
问题描述: 发现Exchange 2010往外发邮件时,有些用户的发件人地址会自动增加BATV= 及 prvs=绪如,这些的特定字符,变成型如prvs=123456=example@example.c ...
随机推荐
- hibernate.hbm2ddl.auto配置详解
hibernate.cfg.xml 中hibernate.hbm2ddl.auto配置节点如下:<properties><property name="hibernate. ...
- python数据结构
. 数据结构¶ .1. 深入列表¶ 链表类型有很多方法,这里是链表类型的所有方法: list.append(x) 把一个元素添加到链表的结尾,相当于 a[len(a):] = [x] . list ...
- asd
弹出输入提示框 :window.prompt(); 24. 指定当前显示链接的位置 :window.location.href="URL" 25. 取出窗体中的所有表单的数量 :d ...
- App Transport Security has blocked a cleartext HTTP (http://)
使用SDWebImage加载“http://”开头的图片报错,错误如下: App Transport Security has blocked a cleartext HTTP (http://) r ...
- Java中对session的简单操作
1.jsp中操作session <% String name=(String)request.getSession().getAttribute("username"); / ...
- 上传到github!
今天课上在冯老师的带领下终于在github上成功上传了东西但是还有很多没用的东西,慢慢研究改进! https://github.com/Hxy94264/GitHubTest https://gith ...
- java压缩和解压字符串,Byte数组,String
在网上找到的压缩解压的工具类,可以压缩String字符串 /*** * 压缩GZip * * @param data * @return */ public static byte[] gZip(by ...
- C# 模拟按下回车键自动登录
private void Form1_Load(object sender, EventArgs e) { //this.Show(); this.Activate(); //this.Focus() ...
- dll 和 lib--初级
今天碰到一个奇怪的问题,一个第三方的库,提供了A.dll和A.lib,编译的时候可以通过,运行的时候一直报错,说找不到A.dll. 我就在main函数那里设了断点,发现没有进main 函数的时候就已经 ...
- Android 中算法问题
1:冒泡排序: 冒泡排序的思路: 相邻的两个数进行比较 (1):首先需要连个for 循环 (2):最外层for 循环控制最里面 for 循环的循环次数 (3):通过设置中间参数的方式进行交换 (4): ...