JSFiddle - React, Tailwind, and code Playground
by serio
HTML
<input type=text />
<button>clicky!</button>
CSS
body { padding: 20px; }
JavaScript
$(function() {
var txt = $('input[type=text]')
, clicky = $('button');
clicky.click(doThatThang);
txt.focus(function() {
txt.keypress(function(e) {
if (e.keyCode === 13) {
doThatThang();
}
});
}).blur(function() {
txt.unbind('keypress');
console.log('unbind the keypress thingy');
});
function doThatThang() {
console.log('do that thang');
}
});