How to get the height of elements under svg

background: d3.js draws a tree with zoom, and the screen will not display when enlarged, so that the downloaded picture will not be fully displayed. So, you want to get the width and height of g under svg

<svg>
    <g class="content">
        ...
    </g>
</svg>

question: cannot be obtained by using the method of jquery. Width (). How can I get the correct value?

Svg
Mar.20,2021

<svg>
    <g class="content" id="g1>
        ...
    </g>
</svg>
<script>
var boxInfo = document.getElementById('g1').getBBox();
var rectInfo = document.getElementById('g1').getBoundingClientRect();

console.log(boxInfo, rectInfo);
</script>
Menu