Q:

Load multiple IDs with jQuery load() - better way

I want to load multiple IDs (#output1 - #output5) from external txt file (output_file.txt) into several IDs (#input1 - #input5) inside my index.html file.
The code below works well, but I believe there is a cleaner way of doing this. 
I am new to JS and programming in general, so I was not able to figure it out yet. Any advice would be much appreciated.
$("#input1").load("output_file.txt #output1"); 
$("#input2").load("output_file.txt #output2");
$("#input3").load("output_file.txt #output3");
$("#input4").load("output_file.txt #output4");
$("#input5").load("output_file.txt #output5");

A:

You can use simple for loop
for(var i = 1; i <= 5; i++) {
  $("#input" + i).load("output_file.txt #output" + i);
}

