0

How is it possible to generate ids in a loop, current I have something like this but did not work:

for(var i=1;i<10;i++)
$("#input-themen-word'+i+'").fileinput({
....
});

In the end it should generate ids like:

#input-themen-word1

#input-themen-word2

#input-themen-word3

#input-themen-word4

#input-themen-word5 ....

John Does Legacy
  • 1,441
  • 6
  • 23
  • 33
  • i think you are looking for `$("#input-themen-word"+i).` – alamnaryab Feb 10 '16 at 16:36
  • You might be better off using a single selector instead of a loop: `$('[id^=input-themen-word]')`. This selects all elements whose ID starts with `input-themen-word`. – Felix Kling Feb 10 '16 at 16:47

1 Answers1

2

It should be like this:

$(("#input-themen-word" + i)).fileinput({

You were trying to mix and match ' with "...

brso05
  • 13,142
  • 2
  • 21
  • 40