I have this logic below that is getting all the value using the class name and then doing a looping. In the loop I am checking if any of the values is true. I wanted to see if there is a way to do this without the loop can I just query the class making sure that just one is true then set the ResultValue to true?
let File = false;
$('.fileClass').each((index, element) => {
console.log(element.value);
if (element.value == true) {
File = "True"
}
});
if (File === false) {
$('#hasFile').val('');
}
$('#ResultValue').html($('#hasFile').val());
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="hidden" id="hf1" name="hf1" class="fileClass" value="False">
<input type="hidden" id="hf2" name="hf2" class="fileClass" value="False">
<input type="hidden" id="hf2" name="hf2" class="fileClass" value="False">
<input type="hidden" id="hasFile" name="hasFile" value="True">
<label id="ResultValue"></label>