This is my jQuery code:
$(document).ready(function() {
$("#nav li a").click(function() {
$("#ajax-content").html("<div id='loading'><img src='{THEME}/images/loading.gif' alt='Loading' /></div>");
$("#nav li a").removeClass('current');
$(this).addClass('current');
var location = this.href +" #answers";
$("#ajax-content").load(location);
return false;
});
});
HTML:
<ul id="nav">
<li><a id="answers" href="test1.html">Page 1</a></li>
<li><a id="answers" href="test2.html">Page 2</a></li>
</ul>
<div id="ajax-content">This is default text, which will be replaced</div>
My question is, can I get contents from different div id for each link?
Somthing like this:
<ul id="nav">
<li><a id="answers1" href="test1.html">Page 1</a></li>
<li><a id="answers2" href="test2.html">Page 2</a></li>
</ul>
<div id="ajax-content">This is default text, which will be replaced</div>
With my jQuery code, I can get content just from #answers. I need to get content for each link, from different div id.
FIDDLE