jQuery verschieben von div-Inhalt statt Klon

Den code, den ich verwende jetzt nur noch die Klone ".comment_post" div-Element und fügt das Formular unter dem Kommentar.

Was ich machen möchte (wenn möglich) zu "bewegen" das ".comment_post" div, um den neuen Speicherort, anstatt Klonen.

Irgendwelche Vorschläge, wie ich dies tun kann?

HTML -

<div class="comment-post">
<form id="addCommentForm" method="post" action="">
<div class="avatar"><img src="http://www.gravatar.com/avatar/ee61e6c16/?s=36&r=g&d=mm" /></div>
<textarea name="txt" id="txt" class="txtcomment"></textarea><button class="btnComment" type="button">Send</button>
</form></div>

<div class="comment">
<span class="avatar"><img src="http://www.gravatar.com/avatar/ee61e6c16/?s=36&r=g&d=mm"></span>
<span class="poster">Jake</a></span><span class="time">5 months ago</span>
<div class="text">just a test comment ...</div>
<div class="reply"><a href="#" onclick="reply(174);">Reply</a></div><div id="new-174"></div>
</div>

<div class="comment">
<span class="avatar"><img src="http://www.gravatar.com/avatar/ee61e6c16/?s=36&r=g&d=mm"></span>
<span class="poster">Jake</a></span><span class="time">5 months ago</span>
<div class="text">another comment ...</div>
<div class="reply"><a href="#" onclick="reply(175);">Reply</a></div><div id="new-175"></div>
</div>

JS

reply = function(id){
    if(!$('#new-'+id+' .comment-post').length) {
        $('.comment-post:first').clone().attr('id', id).appendTo($('#new-'+id));
        $('#new-'+id+' .txtcomment').focus();
        $('#new-'+id+' .txtcomment').autosize();
        $('#new-'+id+' .txtcomment').bind('keydown', charcounter);
        $('#new-'+id+' .txtcomment').bind('keyup', charcounter);
    }
    else
    {
        $('#new-'+id+' .comment-post').remove();
    }          
}
InformationsquelleAutor Brian Smith | 2013-06-16
Schreibe einen Kommentar