Thanks David, Richard and Bryan

I have try with "insertAfter" and this work fine.

But I need to bind a event again in new button that will be created.

HTML

        <div class="add-more">
                <label for="empresas_coligadas_ou_filiais" class="label-
ecf">Empresas Coligadas ou Filiais</label>
                <input name="empresas_coligadas_ou_filiais" type="text"
maxlength="255" />
                <span class="bt-more"></span>
            <span class="bt-less"></span>
        </div>

JS version 1

        /*$('span.bt-more').bind('click', function(){
                var e = $(this).parent();
                var c = e.clone();
                c.insertAfter(e);
                $(c).bind('click', function(){
                        $(this).clone().insertAfter($(this));
                })
        });
I
it's work only first button created.

JS version 2

$('span.bt-more').bind('click', cloneDiv($(this)));

function cloneDiv(e)
{
        var e = $(e).parent();
        var c = e.clone();
        c.insertAfter(e);
        c.bind('click', cloneField(c));
}

This solution generates "too much recursion" message.

Reply via email to