I'm trying focus an input field into a div matching with an another input.
I have to skip reference input (first input value). Then, my code is:
$("#btnSearch").on('click',function() {
input = document.getElementsByTagName('input');
match = 0;
for (i=0;i<input.length;i++) {
if(input[i].value == $("#btnSearch > input").val()) {
match = 1;
}else if (match==1) {
input[i].focus();
break;
}
}
});
But with this code, I focus next input (second input). It doesn't work. Any ideas to improve my code?