Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine two html selections with jquery

Is it possible two combine two html selections in jquery?

var derp1 = $('#derp1').html();
var derp2 = $('#derp2').html();

var combDerp = derp1.add(derp2);

$('#derpina').html(combDerp);

I want to show two certain parts of html into one and display them in another section of the page. Any help is well appreciated :)

like image 592
gardarvalur Avatar asked Dec 15 '22 17:12

gardarvalur


1 Answers

Since you are getting the html of each, you can just concatenate the two.

$('#derpina').html(derp1 + derp2);

Or, you can take the actual nodes and move them.

var derp1 = $("#derp1");
var derp2 = $("#derp2");

$("#derpina").html(derp1.add(derp2));
like image 53
Kevin B Avatar answered Dec 18 '22 10:12

Kevin B