Created
October 15, 2016 13:20
-
-
Save im-sad/263d11d460f45d027814509e87618a43 to your computer and use it in GitHub Desktop.
Get SVG sprite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JQ | |
$.get("svg/sprite.svg", function(data) { | |
var div = document.createElement("div"); | |
div.innerHTML = new XMLSerializer().serializeToString(data.documentElement); | |
document.body.insertBefore(div, document.body.childNodes[0]); | |
}); | |
//JS | |
var ajax = new XMLHttpRequest(); | |
ajax.open("GET", "svg/sprite.svg", true); | |
ajax.send(); | |
ajax.onload = function(e) { | |
var div = document.createElement("div"); | |
div.innerHTML = ajax.responseText; | |
document.body.insertBefore(div, document.body.childNodes[0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment