I want to put for loop for below function i want loop in "textInput" field so i use same function for different Id's linke textInput1, textInput2,.....
function onButtonClick(){
  document.getElementById('textInput').className="show";
}
I want to put for loop for below function i want loop in "textInput" field so i use same function for different Id's linke textInput1, textInput2,.....
function onButtonClick(){
  document.getElementById('textInput').className="show";
}
 
    
    You can pass id in onclick event and use it like below
function onButtonClick(id){
  document.getElementById('textInput'+id).className="show";
}.show{
display:block
}
.hide{
display:none
}<input type='button' value='Add' onclick='onButtonClick(1)'>
<div class='show'>show</div>Or you can also use following but it will run repeatedly when click on button
  function onButtonClick(){
for(let i=0;i<10;i++){
document.getElementById('textInput'+i).className="show";
}
      
    }
