我可以从现有div按钮(添加)单击创建另一个div吗?

时间:2016-02-29 09:29:13

标签: jquery asp.net-mvc-4

<div id="div1">
    @Html.LabelFor(i=>i.FirstName)
    @Html.TextBoxFor(i=>i.FirstName)<br>

    @Html.LabelFor(i => i.LastName)
    @Html.TextBoxFor(i => i.LastName)<br>

    @Html.LabelFor(i => i.Age)<br>
    @Html.TextBoxFor(i =>i.Age)

    <br><input type="submit" onsubmit="submit" id="btn1" value="submit">
    <input type="button" value="add" id="btn2">
    <input type="button" value="sub" id="btn3">

</div>

1 个答案:

答案 0 :(得分:0)

实施例

HTML:     

<div id="content">
    <div>div content</div>
</div>

的javascript:

$(function()  {
    $('#copy').click(function(){
        var content = $('#content div').clone();
        $('#content').after(content);
    });
  });

Fiddle