Skip to content

Instantly share code, notes, and snippets.

@chikoski
Last active December 25, 2015 03:29
Show Gist options
  • Select an option

  • Save chikoski/6910011 to your computer and use it in GitHub Desktop.

Select an option

Save chikoski/6910011 to your computer and use it in GitHub Desktop.
.error{
font-weight: bold;
color: rgb(240, 240, 240);
background-color: rgb(240, 48, 48);
padding: 10px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>押すなよ!</title>
</head>
<body>
<form id="input_form">
<input type="text" id="input" placeholder="テキストを入力してください">
</form>
<p id="output">
ここがリアルタイムに更新されます。
</p>
</body>
</html>
var inputElm = document.getElementById("input");
var formElm = document.getElementById("input_form");
var updateText = function(){
var outputElm = document.getElementById("output");
var inputText = inputElm.value;
outputElm.textContent = inputText;
};
inputElm.onkeyup = updateText;
formElm.onsubmit = function(){
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment