Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming an element with the <code>id</code> of 'deleteInput' is to be clicked to trigger the deletion:</p> <pre><code>$('#deleteInput').click(function(e){ // in case it's an element with a default action: e.preventDefault(); $('#form input').last().remove(); n--; }); </code></pre> <p>The above will simply remove the <em>last</em> <code>input</code> element added, and decrement the <code>n</code> variable.</p> <p>If, on the other hand, you want to remove a specific <code>input</code>, other than the last:</p> <pre><code>$('.deleteInput').click(function(e){ e.preventDefault(); $(this).prev('input').remove(); }); </code></pre> <p>This assumes that the element, with a class of <code>deleteInput</code> will immediately follow the <code>input</code> to be removed. In this case I'm leaving <code>n</code> as-is, and leaving you to find some way of re-using the vacated/emptied 'slot' for the <code>input</code> to be recreated (since a simple decrement would probably cause two elements to (invalidly) share the same <code>id</code>.</p> <p>References:</p> <ul> <li><a href="http://api.jquery.com/click/" rel="nofollow"><code>click()</code></a>.</li> <li><a href="http://api.jquery.com/event.preventDefault/" rel="nofollow"><code>event.preventDefault()</code></a>.</li> <li><a href="http://api.jquery.com/last/" rel="nofollow"><code>last()</code></a>.</li> <li><a href="http://api.jquery.com/prev/" rel="nofollow"><code>prev()</code></a>.</li> <li><a href="http://api.jquery.com/remove/" rel="nofollow"><code>remove()</code></a>.</li> </ul>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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