使用html:
<div id="dynamic-choice">
<a href="http://www.google.com/" class="ajaxLink">click me</a>
<a href="a.nother/page/toload.html" class="ajaxLink">click me 2</a>
</div>
<div id="dynamic-content">
<p>this will be replaced</p>
</div>
和 javascript
<script src="js/jquery-1.8.2.js"></script>
<script>
$(document).ready(function(){
$('a.ajaxLink').click(function(){
var url = $(this).attr('href');
$('#dynamic-content').empty().load(url);
});
return false;
});
</script>
然而,锚只是表现得像普通链接:/