Good day everyone,
I have a simple JQuery code.
When a link is clicked, the HTML content is taken from a page(remotely) and placed in a specified area, like a div in another page.
My question is, how do I add additional links to this script so that each link pulls HTML content from different divs?
Here is a demo.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Practice Template</title>
</head>
<body>
<div id="test">
<p>I'm contents from the div in another HTML file!</p>
<p>I will be called when the link in the external page is clicked.</p>
</div>
</body>
</html>
The above content specifically in the div will be pulled when the link is click in another page.
Here is the page with the calling script:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Practice Template</title>
<script src="jquery-1.5.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.getContent').click(function () {
$('#displayRemoteContent').load('content.html #test');
return false;
});
});
</script>
</head>
<body>
<a href="#" class="getContent">Get Contents</a>
<div id="displayRemoteContent"></div>
</body>
</html>
Thanks everyone!
IC