JSFiddle - React, Tailwind, and code Playground

by mohammadAdil

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 arr = $('#container').find('input').map(function(){
  return $(this).val();
}).get();

var ids = $('#container').find('input').map(function(){
  return $(this).attr('id').replace('item','');
}).get();

$('body').append(String(arr) + " -- " + String(ids));