0

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?

2 Answers 2

3

You can just use normal string concatentation:

var div = '#aSpecificDivinThatPage';
$('#somediv').load('somefile.html ' + div);
Sign up to request clarification or add additional context in comments.

Comments

1

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

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

1 Comment

the content of the filling for the div is in another html page... i can include it on the same page, but that not the question!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.