点击增加一层表单

来源:互联网 发布:淘宝天猫客服 编辑:程序博客网 时间:2024/04/29 05:41

这是一个增加数据库类型

<script>

$(document).ready(function(){
            $("#addTable").click(function(){
                var tr="<tr><td><input type=\"text\" id='add' name=\"add\" placeholder='字段名'/>"+
                        "</td><td><input type=\"text\" id='type' name=\"type\" placeholder='字段类型'/></td><td><input type=\"checkbox\"  id='zhu' ></td><td><input type=\"text\" id='kong' name=\"kong\" placeholder='是否为空'/></td><td><input type=\"button\" id='zeng'  value='增加'/><input type=\"button\" id='del'  value='删除'/></td></tr>";
        $("#table1").append(tr);

            });

// 删除

            $("#deleteTable").click(function(){
                var check = document.getElementsByName("check");
                for(var i=1;i<=check.length;i++){
                    if(check[i].checked){
                        document.getElementById('table1').deleteRow(i);
                    }
                }
            })
        })
// 删除
 $(document).on("click","#del",function()
        {
            var del=$(this);
            del.parent().parent().remove();
        })
</script>


<html>
 <tbody id="table1" > </tbody>  要追加位置的ID
<input type="button" value="增加" id="addTable"/>
</html>

0 0