Can the g composite element tag of SVG be manipulated using the dom node?

for example, the following two lines of code have two combination tags g. I wonder if I can tell the two combination g through the loop through document.getElementclassName (g), like div, which one I clicked with my mouse?
<g class="g">
    <rect x="150" y="100" width="100" height="100" fill="red"></rect>
</g>

<g class="g">
    <rect x="150" y="100" width="100" height="100" fill="green"></rect>
</g>
Mar.19,2021

handle it in the same way as other dom

Array.prototype.forEach.call(
  document.getElementsByClassName('g'),
  (e, i) => e.addEventListener('click', () => console.log(i))
);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e464c2-43153.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e464c2-43153.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?