Article From:https://www.cnblogs.com/-zzc/p/9967387.html
<html>
<head>
    <meta charset=”utf-8″ />
    <title></title>
    <script src=”js/jquery-1.7.2.js”></script>
    <script src=”js/jquery-1.7.2.min.js”></script>
    <script type=”text/javascript”>
        function btnadd() {
            //Click on the Add Text Box (where I used two pictures as add and delete controls)
            $(“thead”).append(“<tr><td>Text 1: & lt; input id=\ txtOne”/& gt; & lt; / td> & lt; td> & lt; text 2: & lt; input id=\ txtTwo\ gt; & lt; / td> & gt;Lt; TD & gt; text 3: & lt; input id=\ txtThree\”/& gt; & lt; / TD & gt; & lt; TD & gt; & lt; a class=\ remove \” & gt; & lt;Id=\”delete”src=\\\\\\\\\\\\\\”Images/cross.png\\\\” /></a></td></tr>;;;;;
            $(“.remove”).bind(“click”, function () {

                //Delete text box

                $(this).parents(“tr”).remove();
            });
        }
        function btnValue() {
            var arr = [];
            var textNum = $(“table thead tr”).children(“td”).find(“input”).length;

            //Loop to get the value of the text box

            for (var i = 0; i < textNum; i++) {
                var text = $(“table thead tr”).children(“td”).find(“input”).eq(i).val();
                arr.push(text);
            }
            var json = JSON.stringify(arr);
            alert(json);
        }
    </script>
</head>
<body>
    <a class=”insert” onclick=”btnadd()”><img id=”add” src=”Images/event.png” /></a>
    <table>
        <thead>
        </thead>
    </table>
    <input type=”button” value=”Get the value “onclick=” btnValue ()”/>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *