JSFiddle - React, Tailwind, and code Playground
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 arrId = [], arrVal = [];
$("input[type='text']").each(function(){
if(this.id && this.id.indexOf("item")===0){
arrId.push(this.id.replace("item",""));
arrVal.push(this.value);
}
});
alert(arrId);
alert(arrVal);