{"id":323,"date":"2011-07-29T13:01:08","date_gmt":"2011-07-29T13:01:08","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=323"},"modified":"2011-07-29T13:01:08","modified_gmt":"2011-07-29T13:01:08","slug":"jquery-combine-lists","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/jquery-combine-lists\/","title":{"rendered":"jQuery combine all lists into one list"},"content":{"rendered":"<p>This little trick comes in handy if your site runs on a CMS. The editors within CMS&#39;s have a tendency to create multiple lists to markup the same set of elements &#8211; many times due to user error.<\/p>\n<p>This approach could potentially be used for any type of element, but I imagine it would be most useful for ordered and unordered lists.<\/p>\n<p><code>if ($(&#39;#content ul&#39;).length &gt; 1) {<br \/>\n\t&nbsp;&nbsp;&nbsp; $(&#39;#content ul li&#39;).each(function(){<br \/>\n\t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; $(&#39;#content ul:first&#39;).append($(this));<br \/>\n\t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; $(&#39;#content ul&#39;).not(&#39;:first&#39;).remove();<br \/>\n\t&nbsp;&nbsp;&nbsp; });<br \/>\n\t}<\/p>\n<p>\t<\/code><\/p>\n<p>Notes:<\/p>\n<ol>\n<li>We&#39;ve dropped in a #content identifier, to ensure that this script doesn&#39;t adjust any lists which are part of your template (drop-down navigation, for example).<\/li>\n<li>If you are using a more recent version of jQuery, you may wish to swap out the :first selector for .first()<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This little trick comes in handy if your site runs on a CMS. The editors within CMS&#39;s have a tendency to create multiple lists to&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[15,5],"tags":[86],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/323"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":0,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}