<input id="a_input" type="text" >
var b = document.getElementById ('a_input'). innerText = '';
<input id="a_input" type="text" >
var b = document.getElementById ('a_input'). innerText = '';
Do not use innerText
, use value
:
var b = document.getElementById('a_input').value;
alert(b);
We use innerText
for objects that can have content in html
, such as div
and span
, to get the content text, and if you want content in html, innerHTML