Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 每行包含一个表的表?_Javascript_Jquery - Fatal编程技术网

Javascript 每行包含一个表的表?

Javascript 每行包含一个表的表?,javascript,jquery,Javascript,Jquery,每当我点击“AddTable”时,它应该创建一个表行,每当我点击“AddRow”时,它应该向表中添加内容,并且应该附加到相应的行中 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <h

每当我点击“AddTable”时,它应该创建一个表行,每当我点击“AddRow”时,它应该向表中添加内容,并且应该附加到相应的行中

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        

    <script type="text/javascript" src="./jquery-1.7.min.js"></script>
    <script type="text/javascript">
        var cnt = 1;

        function remove_row(button) {
            alert($(button).parent().parent());
            //alert($(button).parent().parent().remove());
            alert($(button).parent( "div" ).remove());
        }

        function add_info(button, id) {
            alert($(button).closest(phoneno).value)
            var drop1 = document.getElementById("drop1").value;
            var drop2 = document.getElementById("drop2").value;
            var drop3 = document.getElementById("phoneno").value;
            var appendText = "<tr><td><table><tr><td>" + drop1 + "</td><td>" + drop2 + "</td><td>" + drop2 + "</td><td>" + drop3 + "</td></table></td></tr>";
            $("div:last").after(appendText);
        }

        function add_table(obj, clicked_id) {
            alert(clicked_id);
            var appendTxt= "<div id='row'><tr><td><input type='button' value='remove row' id='remove_tr' onclick='remove_row(this)'><input type='button' hidden='hidden' id ='hidden' value='cnt'></td></tr><tr><td><select id='drop1'><option value='1'>1</option><option value='2'>2</option></select><select id='drop2'><option value='n1'>n1</option></select><input text ='text' id ='phoneno'value=''></td><td><input type='button' class='add' value='Add row' onclick='add_info(this,this.id)'/></td></tr></div>";
            $("tr:last").after(appendTxt);  
            cnt++;
        }
    </script>
 </head>

<body>       
    <table border=1 id="options-table">                 
        <tr>
            <td>
                <input type="button" class='add' id="add_table" value='Add Table' onclick="add_table(this,this.id)"/>
            </td>
        </tr>
    </table>
</body>
</html>

var-cnt=1;
功能删除_行(按钮){
警报($(按钮).parent().parent());
//警报($(按钮).parent().parent().remove());
警报($(按钮).parent(“div”).remove());
}
功能添加信息(按钮,id){
警报($(按钮)。最近的(电话号码)。值)
var drop1=document.getElementById(“drop1”).value;
var drop2=document.getElementById(“drop2”).value;
var drop3=document.getElementById(“phoneno”).value;
var appendText=”“+drop1+“”+drop2+“”+drop2+“”+drop3+“”;
$(“div:last”)。在(附录文本)之后;
}
函数添加_表(obj,单击的_id){
警报(单击了\u id);
var appendTxt=“12n1”;
$(“tr:last”)。在(appendTxt)之后;
cnt++;
}

和。。。它在做什么呢?哈哈,听起来像“每当我加油时,我的车就应该向前开”。嘿,谢谢分享!:)