menardmam
menardmam

Reputation: 9986

jquery.load with div as variable

I would like to use jQuery's load function.

I can write:

$('#somediv').load('somefile.html #aSpecificDivinThatPage');

Now I would like to have a variable as the source div in the html page, how do I write that out?

Upvotes: 0

Views: 248

Answers (2)

cbeer
cbeer

Reputation: 1231

You can just use normal string concatentation:

var div = '#aSpecificDivinThatPage';
$('#somediv').load('somefile.html ' + div);

Upvotes: 3

Andreas Grech
Andreas Grech

Reputation: 107990

You mean you want to copy the html from the source div and put it into another div?

$("#destinationDiv").html($("#sourceDiv").html());

Upvotes: 1

Related Questions