JSFiddle - React, Tailwind, and code Playground

by lostsoul

HTML

<form>
<input name="siblings">
</form>

<div id="total">
hello
</div>

CSS

input{display:block}

JavaScript

$("input[name='siblings']").on('keydown', function() {
    //is it the last input?
    if (this == $("input[name='siblings']:last", this.form)[0]) {
        //insert an empty clone of the current input
        $(this).after($(this).clone(true).val(''));
    }
    
    
    //try to get all elements
    var output;
    $(this).parents('form') // For each element, pick the ancestor that's a form tag.
           .find(':input') // Find all the input elements under those.
           .each(function(i) {
        //alert(this.value+ " = " + i);
               output += this.value;
    });
    $("div#total").append("value = " + output + "<br>");
    
});