Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>form</title>
</head>
<body>
<form action="#">
  <input type="text" name="name" id="input" placeholder="John" />
  <input type="submit" value="Submit" id="btn" />
</form>
</body>
</html>
window.onload = function () {
  clickFunction();
};
function clickFunction() {
  document.getElementById('btn').onclick = function(evt) {
    alertInputValue();
  };
}
function alertInputValue() {
  var inputField = document.getElementById('input').value;
  console.log(inputField);
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers