JSFiddle - React, Tailwind, and code Playground
HTML
<input type="hidden" class="code" barcode="567" total_quantity="3" name="product1" value="Nokia rita" id="product-10105">
<input type="hidden" class="code" barcode="567" total_quantity="3" name="product1" value="Nokia rita" id="product-10105">
<input type="hidden" class="code" barcode="567" total_quantity="3" name="product1" value="Nokia rita" id="product-10105">
<input type="hidden" class="code" barcode="200" total_quantity="3" name="product1" value="book" id="product-200">
JavaScript
function getCount(barcode){
var code = document.getElementsByClassName('code') ;
var length = code.length ;
var count = 0 ;
for(var i = 0 ; i < length ; i++){
if(code[i].attributes['barcode'].value == barcode) count++ ;
}
return count ;
}
// Test
alert(getCount(567)) ; // 3
alert(getCount(200)) ; // 1