How to pass input data to javascript and then present it

Asked

Viewed 63 times

0

I have this code to fetch the value of my input

<Script>

 var name = document.getElementById("name").value;

I would like to know how to introduce you in spam for example

1 answer

3


Follow a simple example using javascript only.

var mostrarNome = function (){
  var exibicao = document.getElementById("exibir");
  var nome = document.getElementById("nome").value;
  
  exibicao.innerText = nome;  
  
}
<input type="text" id="nome" />
<br />
<button type="button" onclick="mostrarNome()">Exibir</button>
<br />
<span id="exibir"></span>

Browser other questions tagged

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