how does this code works and remembering each filed index ;i want the execution and the call back function and manipulating it with let declarition and with var in details please
<code>let elemnt=document.querySelectorAll("[type='text']");
window.onload=function(){
elemnt[0].focus();
}
for(let i=0;i<elemnt.length;i++){
console.log(i);
elemnt[i].addEventListener('input',function(event){
debugger;
if(elemnt[i].value.length===1){
elemnt[i+1].focus();
}
});
}
</code>
<code>let elemnt=document.querySelectorAll("[type='text']");
window.onload=function(){
elemnt[0].focus();
}
for(let i=0;i<elemnt.length;i++){
console.log(i);
elemnt[i].addEventListener('input',function(event){
debugger;
if(elemnt[i].value.length===1){
elemnt[i+1].focus();
}
});
}
</code>
let elemnt=document.querySelectorAll("[type='text']");
window.onload=function(){
elemnt[0].focus();
}
for(let i=0;i<elemnt.length;i++){
console.log(i);
elemnt[i].addEventListener('input',function(event){
debugger;
if(elemnt[i].value.length===1){
elemnt[i+1].focus();
}
});
}
and thanks
i wanted to understand how the code worked
New contributor
mina is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.