Is it possible to store an HTML class name like class="group01" into an array then call it to run a jQuery property like .show()? Below I wrote an example of what I'm trying to do. I'm kinda so-so when it comes to javascripting arrays.
Example:
<div class="stuff group01"></div>
<div class="stuff group02"></div>
<div class="stuff group03"></div>
<script>
$(function() {
$('.stuff').hide();
const classArray = ['.group01','.group02','.group03'];
var pNum = '1; //will change with a dropdown input element
switch (pNum) {
case pNum = '1':
$(classArray[0]).show();
$(classArray[1][2]).hide();
break;
case pNum = '2':
$(classArray).show();
$(classArray[0][2]).hide();
default:
$('.group03').after('<p>ERROR</p>');
}
});
</script>
End result should be that the other div elements with the classname of group01 etc. should hide according to what dropdown input is selected.
If this is not possible, how would you go about making something thats similar to this logic? I tried looking around but no one really seem to have an answer to this particular situation.