index.html :
<div id="divTestArea2"></div>
<script type="text/javascript">
$("#divTestArea2").load("index-2.html #test");
</script>
index-2.html :
<div id="test"><b>Hello World!</b></div>
Why the "load" doesn't work?
index.html :
<div id="divTestArea2"></div>
<script type="text/javascript">
$("#divTestArea2").load("index-2.html #test");
</script>
index-2.html :
<div id="test"><b>Hello World!</b></div>
Why the "load" doesn't work?
Hypotheses:
$ is not yet defined; your script may need to be run after jQuery is included in your page. You should see a console error if this is the case.index-2.html is not a valid relative URL based on the current page's URL. Look at your developer tool's network tab to see if the request for index-2.html is being performed. If you're getting a 404 error, then maybe the URL isn't correct.Edit
Now that you've posted the error, we know the cause is #1; $ will only be defined if you're including jQuery in your page. If you already have that script tag, move your code to after that. If you don't, try adding something like this:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Try to add the # char to select the element by id and put your code inside the ready event.
$(document).ready(function() {
$("#divTestArea2").load("index-2.html");
});
You could separate the div into another file to get only the necessary part instead trying to read a div inside the file.