0

I'm trying to remember how to associate HTML and JS through different actions, so I just wrote a simple reverse script (any number would be turned into a string and reversed)

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>Number Reverser</h1>
<script>
    function Reverser(n){

        n = n + "";
        return n.split("").reverse().join("");
    }

function ExecuteRev(){
    console.log(Reverser());
}
</script>
<input id="bubu">
<button onclick="ExecuteRev()">REVERSE 'EM</button>

</body>
</html>

The ridiculous part is that the console returned

denifednu

My genius JS level managed to reverse the error itself.

How I can connect the input to the function to be executed on the button press and displayed in a div (any div, not console)?

Tunaki
  • 132,869
  • 46
  • 340
  • 423

1 Answers1

-1

I'm not entirely sure what you mean but I think you might be talking about using the DOM. For instance, to update a div with id="x", do the following.

document.getElementById("x").innerHTML = "New content";