How do i make a button that can change the value of a text?

can someone help me pls

<p id="t">Hi</p>
<button id="b" onclick="changeText()">Change me</button>
<script>
function changeText(){
    document.getElementById.innerHTML("t") = "new text"
}
</script>

This is the basic idea, onclick isn’t very proper (you should use event listeners) but it works just fine.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.