JSFiddle - React, Tailwind, and code Playground
by rufwork
HTML
<body>
<form>
<input type="text" id="txt" />
<input type="button" id="go" value="Click Me!" />
<div id="outige"></div>
</form>
</body>
JavaScript
// The document.addEventListener replicates $(document).ready() for
// modern browsers (including IE9+).
// More here: http://stackoverflow.com/a/21814964/1028230
// Unfortunately, it borks jsFiddle, so it's commented out here.
//document.addEventListener("DOMContentLoaded", function() {
var go = document.getElementById("go"),
txt = document.getElementById("txt"),
outige = document.getElementById("outige");
if (txt && go) {
txt.addEventListener("keypress", function (e) {
if (event.keyCode === 13) {
go.click();
e.preventDefault();
}
});
go.addEventListener("click", function () {
outige.innerHTML += "Clicked!<br />";
});
}
//});