Insert html code into a div using JQuery

By | August 26, 2009

When you want to insert a certain HTML code into one DIV you can use the following html code:

html>
<head>
<title>Header&Footer import</title>
<script src=”jquery-latest.js” type=”text/javascript”></script>
<script type=”text/javascript”>
function loadContent(id) {
$(“#copy_header”).load(“http://mydomain.com/header.htm”);
$(“#copy_footer”).load(“http://mydomain.com/footer.htm”);
}
</script>
</head>
<body onLoad=”loadContent();”>
<div id=”copy_header” style=”width: 1000px; height: 150px;”>
Header is loading..
</div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<br />
<br />
<div id=”copy_footer” style=”width: 1000px; height: 30px;”>
Footer is loading..
</div>
</body>
</html>
html>
<head>
<title>Header&Footer import</title>
<script src=”jquery-latest.js” type=”text/javascript”></script>
<script type=”text/javascript”>
function loadContent(id) {
$(“#copy_header”).load(“http://mydomain.com/header.htm”);
$(“#copy_footer”).load(“http://mydomain.com/footer.htm”);
}
</script>
</head>
<body onLoad=”loadContent();”>
<div id=”copy_header” style=”width: 1000px; height: 150px;”>
Header is loading..
</div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<br />
<br />
<div id=”copy_footer” style=”width: 1000px; height: 30px;”>
Footer is loading..
</div>
</body>
</html>

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.