jquery实现html动态表并提交,jQuery+HTML动态表格的实现

动态表格

.div{

width: 95%;

float: left;

margin-top: 30px;

align: center;

margin: 0 auto;

}

.tableStyle

{

display: none;

border-collapse: collapse;

width:50%;

}

td

{

font-size:12px;

height:25px;

border:1px solid #CCD5E8;

}

.btn {

font-size:12pt; color: #003399;

border: 1px #003399 solid;

color:#006699;

border-bottom: #93bee2 1px solid;

border-left: #93bee2 1px solid;

border-right: #93bee2 1px solid;

border-top: #93bee2 1px solid;

background-color: #e8f4ff;

cursor: pointer;

font-style: normal ;

width:80px;

height:22px;

font-family:Verdana;font-family:Georgia;_font-family:Tahoma;

padding:0 10px 1px;padding:3px 3px 1px;_padding:0 4px 1px;

line-height:18px;line-height:14px;_line-height:16px;

}

--请选择--

载重

速度

点击填写参数

操作结果

var rowCount = 1;

var colCount = 2;

// 获取下拉列表的值,以赋上点击事件

window.onload = function () {

var sel = document.getElementsByName("select")[0];

sel.onchange = function () {

var val = this.value;

switch (val){

case "0":

//addCol();

break;

case "1":

addColDL();

break;

case "2":

addColV();

break;

}

}

}

var html='';

//点击出现表格

function showTable() {

document.getElementById("table").style.display = document.getElementById("table").style.display=="none"?"block":"none";

}

//增加载重列

function addColDL(){

colCount++;

$th = $("

载重");

$col = $("

");

$("#table>thead>tr").append($th);

$("#table>tbody>tr").append($col);

}

//增加速度列

function addColV(){

colCount++;

$th = $("

速度");

$col = $("

");

$("#table>thead>tr").append($th);

$("#table>tbody>tr").append($col);

}

//增加行

function addRow(){

rowCount++;

for(var i=0;i

html += '

';

}

var rowTemplate = '

'+html+'';

var tableHtml = $("#table tbody").html();

tableHtml += rowTemplate;

$("#table tbody").html(tableHtml);

html='';

}

//删除行

function delRow(obj){

var res = confirm('确认要删除吗?');

if(res == true)

{

$(obj).parents("tr").remove();

}

rowCount--;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值