What is the returned value of a clicked <button>?

I want to get the returned value of a clicked button, and then use it to make an if statement. All the answers that I read here about people trying to do that are either very old using old script that doesn’t work anymore, or not the same case.

function remove() {

    if (document.getElementById("removing").value == true) {

        document.getElementById("test").style.backgroundColor = "red";
    }
}
<div id="test">test</div>
<button id="removing" onclick="remove()">Remove a word</button>

I have tried using the value property, and onclick, but non of them equal true when the button is clicked.

I tried using alert to display the value, but it displays nothing.

Does clicking a button actually returns a value, and if so, what is it?

33 thoughts on “What is the returned value of a clicked <button>?”

Leave a Comment