开发者

Jquery clear form in a section

开发者 https://www.devze.com 2023-02-09 18:50 出处:网络
for the following: <div cla开发者_如何学编程ss=\"section grouping\"> <div class=\"sectionControl\">

for the following:

<div cla开发者_如何学编程ss="section grouping">
    <div class="sectionControl">
        <div class="parent row errorOn">
            <div class="validGroupControl">
                <div class="row2 itemWrap clearfix">
                    <label>Login1 (adress e-mail)<span class="iconReq">&nbsp;</span>:</label>
                    <input type="text" class="text">
                </div>
                <div class="itemWrap clearfix">
                    <label>Input field1<span class="iconReq">&nbsp;</span>:</label>
                    <input type="password" class="text">
                </div>
                <a href="#" class="iconClose" onclick="$(this).closest('div.parent').remove();" title="remove">remove</a>
            </div>
        </div>
    </div>
    <div class="row addControl">
        <a href="#" class="button" onclick="$('div.sectionControl').append($('div.sectionControl div.parent:last').html());">Add</a>
    </div>
</div>

when I run this:

$('div.addControl a.button').click(function () {
    var parent = $(this).closest('.section.grouping').find('.parent:last');
    parent.after(parent.clone());
});

it clones 'parent' section which works great. But i want it to clone it without values in the input fields.

what's the best way to clear all input fields in a section? thanks


Can't see any reason why this won't work..

var oClone = parent.clone();
oClone.find("input").val("");
parent.after(oClone);
0

精彩评论

暂无评论...
验证码 换一张
取 消