How to make input content appear on Alert?

Asked

Viewed 631 times

0

To illustrate what I want, it’s like I write something on input and when you press the button, appear, in the alert, the text I wrote.

In Javascript:

    function myFunction (){

        var input = document.querySelector('.inputt');
        var text = document.createTextNode('');
        b_i.innerHTML = textt;

        alert(textt);
    }

In the HTML:

   <input class='inputt'/>
   <button onclick='myFunction'></button>
  • 1

    alert( document.querySelector('.inputt').value )

  • vlw bro you have no idea how long was wanting this kk

1 answer

2

HTML

<input type="text" id="inputId">
<input type="submit" value="Enviar" onclick="MyFunction()">

JS

function MyFunction(){
    var id = document.getElementById("inputId").value;
    alert(id);
}
  • Thanks friend was not knowing how to use this . value why I was testing on getclassname, queryselector and others find out that only picks up some, I will continue testing for me to get the morning. hugs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.