1
<input id="a_input" type="text" >
var b = Document.getElementById('a_input'). innerText = '';
//There are ways you can return to me what I typed in the Alert input to make it easier ??
1
<input id="a_input" type="text" >
var b = Document.getElementById('a_input'). innerText = '';
//There are ways you can return to me what I typed in the Alert input to make it easier ??
0
Do not use innerText
, use value
:
var b = document.getElementById('a_input').value;
alert(b);
We use innerText
for objects that may have content in html
, as div
and span
, to get the text content, and if you want the html content, innerHTML
Browser other questions tagged input
You are not signed in. Login or sign up in order to post.
bro forget to say from the button rs that when I click on it the value goes pro Alert
– Leandro Lobo
then you need to add a Listener to follow the event "onfocus", which happens when the field receives the focus, that is, after clicking on it or navagar on it by TAB, and can do, in the simplest way to understand, so:
<input id="a_input" type="text" onfocus="alert(this.value)" >
– Ricardo Pontual