Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery how to append multiple var's to a div?

i have some var's:

var1 = ('1');
var2 = ('2');
var3 = ('3');

how to append them to a div using jquery appendTo ?

var1, var2, var3.appendTo('.div');

thanks

edit:

var1 = $('<div class="1"></div>');
var2 = $('<div class="2"></div>');
var3 = $('<div class="3"></div>');

i want it to look like this:

<div class="div">
<div class="1"></div>
<div class="2"></div>
<div class="3"></div>
</div>

i can use:

var1.appendTo('.div');
var2.appendTo('.div');
var3.appendTo('.div');

but what if i have 15 vars?? and append alone doesn't do the job

like image 668
Patrioticcow Avatar asked Oct 20 '25 15:10

Patrioticcow


1 Answers

$('.div').append(var1, var2, var3)

whatever a var is

like image 164
Marco Mariani Avatar answered Oct 22 '25 05:10

Marco Mariani