There is a problem here:
var text = document.getElementById('myInput'); text.text();
You have never assigned input text to any variable.
Following the above pattern, you can do:
var txt = document.getElementById('myInput'), txt = text.text();
The second variable updates the previous txt variable to store the text of the original txt variable, which was a selector.
You could do this as well (vanilla javascript, jsfiddle ):
var txt = document.getElementById('myInput').innerHTML; //or var txt = document.getElementById('myInput').textContent;
source share