JSFiddle - React, Tailwind, and code Playground
by lollero
HTML
<input class="firstName" type="text" />
<input class="lastName" type="text" />
<input class="phone" type="text" />
<input class="email" type="text" />
<div></div>
JavaScript
$(function() {
var inputs = {};
$('input').on('keyup', function() {
var _this = $(this);
// Creates variables on keyup.
inputs[ _this.attr('class') ] = _this.val();
// Shows all input variables.
console.log( inputs );
$('div').html( 'Name: ' + ( inputs.firstName || '' ) + ' ' + ( inputs.lastName || '' ) );
});
});