import streamlit as st
import streamlit.components.v1 as components
def my_fun():
#change paragraph text when button clicked
pass
a="""
<div>
<button id="my_btn">Click Me!</button>
<p id='my_para'>Hello word<p>
</div>
"""
components.html(a,height=800,width=1200)
Hi @muchhar_bharat, is this what you are looking for?
import streamlit as st
import streamlit.components.v1 as components
a = """
<script> function changeText(value) { document.getElementById('my_para').innerHTML = "You clicked me using button titled " + value; } </script>
<input type="button" value="Click Me!" id="my_btn" onclick="changeText(this.value);"/>
<p id="my_para">Hello word</p>
"""
components.html(a,height=800,width=1200)
Cheers
Hello Shawn thanks for reply. i want to change text by python function when button clicked or can we call that my_fun() python function from javascript when button clicked. i have large html code inside streamlit.components.v1 and some data get and send from API when button clicked. so i need to call python function. can you give me any suggestion ?