mirror of
https://github.com/feathericons/feather.git
synced 2023-08-10 21:13:24 +03:00
Inject svg using javascript
This commit is contained in:
parent
48269adfe0
commit
3afa82d3db
21
index.html
21
index.html
@ -1,10 +1,25 @@
|
|||||||
<!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>
|
Loading…
x
Reference in New Issue
Block a user