var a = $('.opti').map(function() {
return $(this).attr('value');
}).toArray();
var b = $('.opti').map(function() {
return $(this).attr('vid');
}).toArray();
console.log(a, b);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="hidden" class="opti" value="337" vid="231">
Output
["337"] ["231"]
Question: Above code is return the data in separate array, but what I want is put them into one array, for example it will be one array to store is 2 value, result will be ["337","231"].
.opti? Do you want to store them in an array of arrays (a 2D array containing elements with pairs of data), or a 1D array?