Get value from textbox not working in JavaScript
<p>I want to alert the value of the textbox topValue, but when solve () is called, a textbox does appear, but with no text / value / number</p>

<p>Here is my code:</p>

<pre><code>var topValue = document.getElementById('topValue').value

function solve() {
    alert(topValue);
}
$('#solveButton').click(function () {
    solve();
});
</code></pre>