{"id":2554,"date":"2015-08-16T13:41:18","date_gmt":"2015-08-16T13:41:18","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=2554"},"modified":"2015-08-16T13:41:18","modified_gmt":"2015-08-16T13:41:18","slug":"getting-a-list-of-all-css-color-properties-with-jquery","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/getting-a-list-of-all-css-color-properties-with-jquery\/","title":{"rendered":"Getting a list of all CSS color properties with jQuery"},"content":{"rendered":"<p>The list of CSS properties available is always changing, so the best way to get the list of values is by querying the brwoser.<\/p>\n<p>In this technique, we grab all DOM elements on the page, get each CSS style, and filter to the list containing the word &#8220;color&#8221;, which gives us a pretty good list:<\/p>\n<pre lang=\"Javascript\">\nvar elem = $('*')\n\nfunction getStyles(i, v) { \n  var s = window.getComputedStyle(v); \n  \n  var keys = []; \n\n  for (var i = 0; i < s.length; i++) { \n    keys[keys.length] = s.item(i); \n  } \n\n  return keys; \n}\n\nvar props = \n  elem.map(getStyles)\n      .filter(\n        function(i, v) { \n          return v.indexOf('color') > 0 \n        });\n\n$.unique(props);\n<\/pre>\n<pre>\n[\"-webkit-text-fill-color\", \n \"stop-color\",\n \"-webkit-text-stroke-color\",\n \"background-color\",\n \"-webkit-print-color-adjust\",\n \"-webkit-text-fill-color\",\n \"outline-color\",\n \"-webkit-column-rule-color\",\n \"lighting-color\",\n \"-webkit-text-emphasis-color\",\n \"-webkit-tap-highlight-color\",\n \"border-bottom-color\",\n \"border-right-color\",\n \"border-left-color\",\n \"-webkit-text-stroke-color\",\n \"-webkit-text-emphasis-color\",\n \"flood-color\",\n \"border-bottom-color\",\n \"border-left-color\",\n \"-webkit-text-emphasis-color\",\n \"-webkit-column-rule-color\",\n \"border-top-color\",\n \"-webkit-column-rule-color\",\n \"-webkit-print-color-adjust\",\n \"-webkit-text-emphasis-color\",\n \"border-top-color\",\n \"border-bottom-color\",\n \"border-top-color\",\n \"-webkit-print-color-adjust\",\n \"border-top-color\"]\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The list of CSS properties available is always changing, so the best way to get the list of values is by querying the brwoser. In this technique, we grab all DOM elements on the page, get each CSS style, and filter to the list containing the word &#8220;color&#8221;, which gives us a pretty good list: &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/getting-a-list-of-all-css-color-properties-with-jquery\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Getting a list of all CSS color properties with jQuery&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[129,313,343],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2554"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=2554"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2554\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=2554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=2554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=2554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}