Dynamically attribute unique IDs to a specific class name elements inside a CMS collection

Hi ,

I have a one page portfolio in CMS.
Each section populated in CMS have a div block class named “titre”

I Want to give a unique ID of = ’ titre-[ x ] ’ to each element of class=“titre”
(with [ x ] as a number CMS field )

How could I code this in an Embed code?

I’ve tried this but this is not working:

<script>
var titr = element.getElementsByClassName('titre');
 titr .id = "titre-</order_number_CMS_Field/>";
</script>

the selector element.getElementsByClassName(‘titre’); doesn’t work.

Do you have a magic trick to attribute a unique ID to each element of a specific class populate by CMS ?

Here is my public share link: https://preview.webflow.com/preview/julienwidmer?utm_medium=preview_link&utm_source=designer&utm_content=julienwidmer&preview=b1c6e4b8e968903cb0a0e7087aa1063b&workflow=preview
link : https://julienwidmer.webflow.io/