const elems = [...document.querySelectorAll('.class1')];
const index = elems.findIndex(n => n.classList.contains('class2'));
const elems = document.querySelectorAll('.class1');
let index = elems.length;
while (--index >= 0 && !elems[index].matches('.class2')) ;
const index = Array.prototype.indexOf.call(
document.querySelectorAll('.class1'),
document.querySelector('.class2')
);
const data = $('table tr')
.get()
.map(tr => $('input', tr).get().map(n => $(n).val()))
.filter(row => row[row.length - 1])
.map(row => `(${row.map(n => `'${n}'`).join(', ')})`);
$('input').on('input', function() {
$(this).val((i, v) => Math.max(this.min, Math.min(this.max, v)));
});
document.querySelector('input').addEventListener('input', ({ target: t }) => {
t.value = Math.max(t.min, Math.min(t.max, t.value));
});