Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In the above code, you haven't included the jquery and jquery-ui libraries. For example, put the following in the <code>&lt;head&gt;</code> section of your page:</p> <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>Also, you should add <code>&lt;head&gt;</code> and <code>&lt;body&gt;</code> tags around the appropriate content, so your page would look more like this:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var count = 1; $(function(){ $('#add_item').click(function(){ count++; $('#container').append('&lt;li id="item_' + count +'"&gt;' + count + '° posto: '+ '&lt;input type="text" id="item_' + count + '" name="items[]" type="text" /&gt;&lt;input type="submit" class="del_item" value="Elimina" /&gt;&lt;br /&gt;&lt;/li&gt;'); return false; }); $('form').on('click', '.del_item', function(){ count--; $(this).parent().remove(); return false; }); $('#container').sortable(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;ul id="container"&gt; &lt;li id="item_1"&gt;1° posto: &lt;input type="text" id="item_1" name="items[]" /&gt; &lt;input type="submit" class="del_item" value="Elimina" /&gt;&lt;br /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;input type="submit" name="add_item" id="add_item" value="Aggiungi" /&gt;&lt;br /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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