How do I get the values of the text inputs and add them? [duplicate]

  html, javascript

I’ve been trying to get what I typed inside 3 text inputs and join them together. How would I go around doing this?

I’ve tried this and have had no luck.

<!DOCTYPE html>
                <label>Number </label>
                <input type="text" id="dataElement1">
                <label>First Name </label>
                <input type="text" id="dataElement2">
                <label>Last Name </label>
                <input type="text" id="dataElement3">
                var dataElement1 = document.getElementById("dataElement1").value
                var dataElement2 = document.getElementById("dataElement2").value
                var dataElement3 = document.getElementById("dataElement3").value
                function dataGet() {
                    const fullData = dataElement1 + dataElement2 + dataElement3
                    document.getElementById("output").innerHTML = fullData
            <button type="button" onclick="dataGet()">Get Data</button>
            <p id="output">None</p>

Source: Ask Javascript Questions