When I navigate through the menu I want only the contentarea div to change and not reload the whole page. I want to use the jquery load function to read a div from another page (from members.html div colTwo) and insert it onto the page (into div contentarea). I have been trying but couldn't get it to work.
Any help editing this script would be helpful!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Title</title>
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src ='http://code.jquery.com/jquery-1.9.1.min.js'</script>
<script type="text/javascript">
$(document).ready(function() {
function memberspage(){
$('#contentarea').load('members.html #colTwo');
}
});
</script>
<body>
<div id="header">
<h1>My Title</h1>
</div>
<div id="content">
<div id="colOne">
<div id="menu1">
<ul>
<li><a href="#" onclick='memberspage()'>Members</a></li>
</ul>
</div>
<div class="margin-news">
<h2>Recent Updates</h2>
<p><strong>None At This Time</strong> </p>
</div>
</div>
<div id="contentarea"><h2>Starting Text</h2></div>
<div style="clear: both;"> </div>
</div>
</body>
</html>
See Question&Answers more detail:os