JSFiddle - React, Tailwind, and code Playground

HTML

<input id="dynamic1" data-group-type="animal" data-group="y1,y2" />
<input id="dynamic2" data-group-type="vegetable" data-group="y3,y4" />

JavaScript

console.log($('input[data-group]')) // all
    
console.log($('input[data-group-type^="animal"]')) // starts with 'animal'
console.log($('input[data-group-type*="l"]')) // contains 'l'
console.log($('input[data-group-type!="animal"]')) // not 'animal'
// others: http://api.jquery.com/category/selectors/