0

Hi all I am trying to access the id of a div in lwc with the help external js(static resource) where code is like document.getElementById("createsulightning"); for <div id="createsulightning"></div> but when it renders in the community it shows <div id="createsulightning-18"> with any random no. so what changes need to be updated in js or html for working like situations . here is screenshot attached for inspecting element in chrome

enter image description here

1

As inspired by the two answers to this post, try using this.template.querySelector() on a data-id property that you define on the child, or any other selector property.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.