Table of Contents is not working with CMS richtext

I thought maybe TOC script runs earlier before Webflow render the CMS content. then I have put the TOC script before the body tag, but its also not working.

I have test the TOC Attribute with static richtext, its working. when I connect that richtext to CMS, TOC is not working.

Hey @lissanh95! Can you please share a link?

here is the read-only link:
https://preview.webflow.com/preview/appdealpage?utm_medium=preview_link&utm_source=designer&utm_content=appdealpage&preview=d69da8a9f6e9266064138d86410598f5&pageId=65424f8376bc50eb0656c190&itemId=668182b6e39d6e12d17075b1&locale=en

and here is the live link:

TOC atrribute script adding IDs to richtext but not creating link elements. so I added my code to create link elements according to the richtext IDs.

TOC attribute script also working in other pages with CMS richtext. not sure why its not working in this page.

Hey @lissanh95! Sorry for the delay! I see the ToC is working as it should. Did you have to add anything on top?