bobo2000
bobo2000

Reputation: 1877

Dynamic selector

I am trying to do this:

var divString = '#sContainer' + [index];
$(divString).append(SSDisplay);

So that it is

var divString = '#sContainer' + [index];
$('#sContainer0').append(SSDisplay);
$('#sContainer1').append(SSDisplay);
$('#sContainer2').append(SSDisplay);

It doesn't seem to be working. I have also tried

$('#sContainer' + [index]).append(SSDisplay);

Any idea how I can get the jquery selector to do this dynamically?

Upvotes: 1

Views: 45

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324790

You are repeatedly appending the same SSDisplay.

Try:

$('#sContainer' + index).append( SSDisplay.clone(true) );

Upvotes: 1

Related Questions