st.markdown and st.html don’t support scripting. You can use components, but st.components.v1.html is iframed, so your script needs to access the window’s parent’s document. For example: How would I add a JavaScript to the text_area so that it changes the function of the "tab" key? - #2 by mathcatsand