SVG as Object
Wed Oct 09 2024 06:26:18 GMT+0000 (Coordinated Universal Time)
Saved by
@omnixima
#javascript
<object class="mySvg" type="image/svg+xml" data="/wp-content/uploads/2024/09/Carrs-Hill-Partners-Logo.svg"></object>
or
<embed class="mySvg" src="your-svg-file.svg" type="image/svg+xml">
<embed class="mySvg" src="another-svg-file.svg" type="image/svg+xml">
***
//Script for Changing the PATH color
document.querySelectorAll('.mySvg').forEach(function(svgElement) {
svgElement.addEventListener('load', function() {
var svgDoc = svgElement.contentDocument;
var paths = svgDoc.querySelectorAll('path');
paths.forEach(function(path) {
path.setAttribute('fill', '#4E738A');
});
});
});
content_copyCOPY
Comments