JSFiddle - React, Tailwind, and code Playground

by alepac

HTML

<div id="container">

<div>
 <span>
   <input type="text" id="item1" value="AA"/>
 </span>
</div>

<div>
 <span>
   <input type="text" id="item2" value="BB"/>
 </span>
</div>

<div>
 <span>
   <input type="text" id="item3" value="CC"/>
 </span>
</div>

</div>

JavaScript

var vals = [];
    var ids = [];
    $("#container input").each(function(){
        vals.push($(this).val());
        ids.push($(this).attr("id").replace("item", ""));
    });
alert("ids = "+ ids + "\nvals = " + vals);