Skip to content

Instantly share code, notes, and snippets.

@samnajian
Created September 27, 2017 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samnajian/09ddf340175d3721c24cc297efe0c375 to your computer and use it in GitHub Desktop.
Save samnajian/09ddf340175d3721c24cc297efe0c375 to your computer and use it in GitHub Desktop.
Trick to change svg fill color
document.addEventListener('DOMContentLoaded', function() {
/**
* Refrence to object element that has svg as data attribute
**/
const obj = document.querySelector('object');
const svg = obj.contentDocument.querySelector("svg");
svg.style.fill = "red" // change fill color to red
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment