I have two lists in Javascript:
- newClass - which is a list of strings (class names)
- hiddenVals - which is a list of hidden input elements from
$('input:hidden')
which contain values...
I basically want to be able to go through the list of newClass and check if there is a match in hiddenVals. If so, I will get the value of that hiddenVal.
I have the following working, but I can help but think JQuery has a more concise way of doing it:
var newClass = ui.item[0].parentElement.classList;
var hiddenVals = $j('input:hidden');
var newStatusId = -1;
for (var i = 0; i < hiddenVals.length; i++) {
var hiddenClass = hiddenVals[i].classList[0];
for (var x = 0; x < newClass.length; x++) {
var test = newClass[x];
if (test == hiddenClass) {
newStatusId = hiddenVals[i].value;
}
}
}
I hope that makes sense and someone can help refactor this appropriately.