{"id":60,"date":"2007-07-12T01:52:31","date_gmt":"2007-07-12T05:52:31","guid":{"rendered":"http:\/\/www.virtualroadside.com\/blog\/index.php\/2007\/07\/12\/jquery-snippet\/"},"modified":"2007-07-12T01:55:13","modified_gmt":"2007-07-12T05:55:13","slug":"jquery-snippet","status":"publish","type":"post","link":"https:\/\/www.virtualroadside.com\/blog\/index.php\/2007\/07\/12\/jquery-snippet\/","title":{"rendered":"jQuery snippet:"},"content":{"rendered":"<p>Here is a neat jQuery snippet that you can use to create extra elements in a form, underneath (mostly) the previous element. Took longer than it should have to create this since I didn&#8217;t quite understand the behavior of &#8220;before&#8221; and &#8220;after&#8221;&#8230; ie, a parent node has to exist for them to work.<\/p>\n<pre>\r\n&lt;input name=\"field[]\" type=\"text\" \/&gt; &lt;a href=\"#\" onclick=\"$(this). before('&lt;br\/&gt;'). before($(this). prev(). prev(). clone()); return false;\" href=\"\" &gt;+&lt;\/a&gt;<\/pre>\n<p>This snippet works especially well inside of a table. \ud83d\ude42 Unfortunately, I don&#8217;t have a demo of the code since I don&#8217;t have jQuery enabled on this blog.. yet. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a neat jQuery snippet that you can use to create extra elements in a form, underneath (mostly) the previous element. Took longer than it should have to create this since I didn&#8217;t quite understand the behavior of &#8220;before&#8221; and &#8220;after&#8221;&#8230; ie, a parent node has to exist for them to work. &lt;input name=&#8221;field[]&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,10,16],"tags":[],"_links":{"self":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/60"}],"collection":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":0,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}