Jquery content replacing not working

Discussion in 'jQuery' started by cluongo18, Dec 9, 2011.

  1. #1
    On my website I tried following a tutorial to set up a basic jquery script that will replace the content on a page into a div when a link is clicked:

    http://seelooh.com/portfolio.php

    When "websites, graph design, 3d/level editing, screen-casts" is clicked the corresponding page for each, is supposed to load its content_area div below where it says hey.

    but its still linking me to the page.

    portfolio page html:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title>Seelooh | Web Designer/Developer</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="nav.js"></script>
    </head>
    
    <body>
    <div id="leftBar"> <!-- Begin Sidebar div-->
    		
    		<h1 class="logo">Seelooh</font></h1>
    		<?php include("navigation.php"); ?>
    
    		
    </div> <!-- End Side bar div-->
    
    <div id="holder"> <!-- Begin Content Div -->
    
    	<b class="welcome">Portfolio <i class="name">Chris Luongo</i>.</b><br />
    	<br />
    	
    	<div id="portlink">
    	<a class="menu_top" href="websites.php">Websites</a> |
    	<a class="menu_top" href="graphicdesign.php">Graphic Design</a> |
    	<a class="menu_top" href="3d.php">3D/Level Editing</a> | 
    	<a class="menu_top" href="video.php">Screen-Casts</a> |
    	</div>
    	<br/>
    	
    	hey
    j	<div id="content_area">
    	</div> <!-- end content area -->
    	
    </div> <!-- End Content Div-->
    </body>
    </html>
    
    Code (markup):

    nav.js (script code)
    $('.menu_top').click(function() {
    	var href = $(this).attr('href');
    	$('#content_area').load(href);
    	
    	
    	return false;
    });
    Code (markup):
    I'm thinking maybe I linked to jquery.js wrong? I really dont see what I did wrong
     
    cluongo18, Dec 9, 2011 IP
  2. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #2
    i think you have executed the nav.js script too early..
    try to move this:
    
    <script type="text/javascript" src="nav.js"></script>
    
    HTML:
    before you close the body tag.. something like this:
    
    </div> <!-- End Content Div-->
    <script type="text/javascript" src="nav.js"></script>
    </body>
    
    HTML:
     
    JohnnySchultz, Dec 13, 2011 IP
  3. cluongo18

    cluongo18 Member

    Messages:
    855
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #3
    Bingo! Thanks Johnny, that worked.
     
    cluongo18, Dec 14, 2011 IP
  4. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #4
    You're welcome!
     
    JohnnySchultz, Dec 15, 2011 IP
  5. myst_dg

    myst_dg Active Member

    Messages:
    224
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #5
    
    $(document).ready(function() {
    	$('.menu_top').click(function() {
    		var href = $(this).attr('href');
    		$('#content_area').load(href);
    		return false;
    	});
    });
    
    Code (markup):
     
    myst_dg, Dec 15, 2011 IP