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(comb
Solution 1:
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));
Solution 2:
Solution 3:
Just concatenate them.
var combDerp = derp1+derp2;
Solution 4:
You can also use JQuery .Append() if you are trying to append HTML.
Solution 5:
If you want the elements to move, you should just use:
$('#derp1, #derp2').contents().appendTo('#derpina');
If you want to copy them, you should use:
$('#derp1, #derp2').contents().clone().appendTo('#derpina');
Post a Comment for "Combine Two Html Selections With Jquery"