Commit 3afa82d3 authored by Cole Bemis's avatar Cole Bemis

Inject svg using javascript

parent 48269adf
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Feather</title> <title>Feather</title>
</head> </head>
<body> <body>
<a href="svg/air-play.svg">Download air-play</a>
<div class="svg-container"></div>
<script>
const iconName = 'square';
fetch(`./icons/${iconName}.svg`)
.then(response => response.text())
.then(svgText => {
const svgDocument = new DOMParser().parseFromString(svgText, 'image/svg+xml');
const svgIcon = svgDocument.querySelector('svg').cloneNode(true);
const svgContainer = document.querySelector('.svg-container');
svgContainer.appendChild(svgIcon);
});
</script>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment