How to access a streamlit element?


How can I access a streamlit element? I’ve been trying to use JS DOM by st.components, but nothing happens.

Any suggestion?

Below my code trying to scroll to the subheader by class name.

st.components.v1.html("""<script>document.getElementByClassName("markdown-text-container stMarkdown").scrollIntoView()</script>""")

Hi @Alexandre_FG, welcome to the Streamlit community!

The html() and iframe() methods don’t work this way, they are both static components, meaning they only display content they don’t return values. To be able to pass values back and forth, you’d need to use the bi-directional component functionality, which is significantly more involved than a quick line or two in a Streamlit app.

I’ll try. Thanks!