Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
99
rated 0 times [  103] [ 4]  / answers: 1 / hits: 26097  / 12 Years ago, thu, june 21, 2012, 12:00:00

Basicily i have a index.html shown below..



<html>

<head>

<title>UI Test: Main Menu</title>

<script type=text/javascript src=jquery-1.7.2.min.js></script>
<script type=text/javascript src=general.js></script>

</head>

<body>

<input type=button value=Details onclick=javascript:$('#mainContainer').load('loadpage.html #name1div *');/><br>
<div id=mainContainer>

</div>






The loadpage.html cotaints



<div id=nav1div><h3>1 DIV </h3> </div>
<div id=nav2div><h3>2 DIV </h3> </div>
<div id=nav3div><h3>3 DIV </h3> </div>
<div id=nav4div><h3>4 DIV </h3> </div>


And my objective is to basicly load 1 of the divs at a time in to the main container, i know the load function can load the full page at once but this is NOT what i need to do.



Had a few look at similar questions but cant seem to resolve this..



All help is appreciated thanks guys!


More From » jquery

 Answers
15

The jQuery .load() function allows you to specify a portion of a page to load, rather than just the whole document.



e.g.



$('#mainContainer').load('loadpage.html #nav1div');


Check out the jQuery load() documentation particularly where it regards “Loading Page Fragments”.


[#84759] Wednesday, June 20, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mitchellg

Total Points: 235
Total Questions: 117
Total Answers: 106

Location: Fiji
Member since Wed, Jul 14, 2021
3 Years ago
mitchellg questions
Sun, Jan 10, 21, 00:00, 3 Years ago
Fri, Aug 21, 20, 00:00, 4 Years ago
Fri, Jul 10, 20, 00:00, 4 Years ago
;