Moin,
also das liefert mir einmal das komplette svg-Element und dann das x
-Attribut des Rechtecks:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
function moin() {
let svg = document.getElementsByTagName('svg');
if (svg.length === 0) {
console.warning('No SVG elements found.');
return;
}
console.log(svg[0]);
let r = svg[0].getElementsByTagName('rect');
console.log(r[0].getAttribute('x'));
}
</script>
</head>
<body>
<div class="CHARTWRAPPER">
<svg xmlns:ct="http://gionkunz.github.com/chartist-js/ct" width="100%" height="100%" class="ct-chart-bar" style="width: 100%; height: 100%;">
<rect width="200" height="100" x="100" y="100" style="stroke-width:5;stroke:red;fill:black"/>
</svg>
</div>
<button type="button" onclick="moin()">Klick</button>
</body>
</html>
<svg class="ct-chart-bar" xmlns:ct="http://gionkunz.github.com/chartist-js/ct" width="100%" height="100%" style="width: 100%; height: 100%;"> …
100