{"id":2461,"date":"2015-10-15T05:48:08","date_gmt":"2015-10-15T05:48:08","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=2461"},"modified":"2015-10-15T05:48:08","modified_gmt":"2015-10-15T05:48:08","slug":"jquery-issue-in-removing-items-in-a-dropdown","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2015\/10\/15\/jquery-issue-in-removing-items-in-a-dropdown\/","title":{"rendered":"JQuery issue in removing items in a dropdown"},"content":{"rendered":"<p>If you have a very large dropdown in an html page\u00a0 &#8211; say a few thousand items, and you want to clear all of them, then using jQuery .empty() function is very slow. In most cases, it will hang the browser.\u00a0 The fastest way is to use native javascript.<\/p>\n<p>So instead of<\/p>\n<pre>$('#mydropdown').empty();\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>use<\/p>\n<pre>document.getElementById('mydropdown').items.length = 0;\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>If you have a very large dropdown in an html page\u00a0 &#8211; say a few thousand items, and you want to clear all of them, <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2015\/10\/15\/jquery-issue-in-removing-items-in-a-dropdown\/\" title=\"JQuery issue in removing items in a dropdown\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":2463,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-2461","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=2461"}],"version-history":[{"count":2,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2461\/revisions"}],"predecessor-version":[{"id":2464,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2461\/revisions\/2464"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/2463"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=2461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=2461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=2461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}