Note that there are some explanatory texts on larger screens.

plurals
  1. POCloning once after getting value of textarea
    primarykey
    data
    text
    <p>I have this <a href="http://jsfiddle.net/NgEpS/1/" rel="nofollow">http://jsfiddle.net/NgEpS/1/</a> basically, I am getting the value of a textarea on each form and the appending the value to a child div, everything works.perfect after the first submit, but if you submit more than once the same form, my script is cloning all the previous replies, wondering if there is any way to avoid this.</p> <p><strong>HTML:</strong></p> <pre><code> &lt;div class="post-container"&gt; &lt;form class="reply-form"&gt; &lt;div class="reply-box"&gt; &lt;textarea placeholder="Reply box 1..." columns="10" rows="1" name="comment-input"&gt;&lt;/textarea&gt; &lt;input type="submit" value="Send"&gt; &lt;/div&gt; &lt;div class="post-dropdown"&gt;&lt;/div&gt; &lt;div class="post-dropdown-content"&gt; &lt;div class="post-dropdown-reply"&gt;1&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="post-container"&gt; &lt;form class="reply-form"&gt; &lt;div class="reply-box"&gt; &lt;textarea placeholder="Reply box 2..." columns="10" rows="1" name="comment-input"&gt;&lt;/textarea&gt; &lt;input type="submit" value="Send"&gt; &lt;/div&gt; &lt;div class="post-dropdown"&gt;&lt;/div&gt; &lt;div class="post-dropdown-content"&gt; &lt;div class="post-dropdown-reply hidden"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="post-container"&gt; &lt;form class="reply-form"&gt; &lt;div class="reply-box"&gt; &lt;textarea placeholder="Reply box 3..." columns="10" rows="1" name="comment-input"&gt;&lt;/textarea&gt; &lt;input type="submit" value="Send"&gt; &lt;/div&gt; &lt;div class="post-dropdown"&gt;&lt;/div&gt; &lt;div class="post-dropdown-content"&gt; &lt;div class="post-dropdown-reply"&gt;1&lt;/div&gt; &lt;div class="post-dropdown-reply"&gt;2&lt;/div&gt; &lt;div class="post-dropdown-reply"&gt;3&lt;/div&gt; &lt;div class="post-dropdown-reply"&gt;4&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; p​ </code></pre> <p><strong>JavaScript:</strong></p> <pre><code> function gettingReplyVal() { $('.reply-form').submit(function(e) { var post_clone = $('.post-dropdown-content').first().clone(); var textAreaValue = $(this).find('textarea').val(); $(post_clone).insertBefore($(this).f ind(".post-dropdown-content")).find('.post-dropdown-reply').html(textAreaValue); e.preventDefault(); }); } gettingReplyVal(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload