Results 1 to 3 of 3

Thread: JQuery Content Load

  1. #1
    Join Date
    Oct 2008
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default JQuery Content Load

    Hey i wrote this code to load content without page loads.

    I'm using the JQuery framework and im still quite new to it.

    is it possible to fade the content in an out somehow.

    Code:
    	<script type="text/javascript" >
    		$(document).ready(function(){
    			$('#mainDiv').load("Home.html");
    			$('li.home').click(function() {
    				$('#mainDiv').load("Home.html");
    		});
    			$('li.about').click(function() {
    				$('#mainDiv').load("About.html");
    		});
    			$('li.products').click(function() {
    				$('#mainDiv').load("Products.html");
    		});
    			$('li.tech').click(function() {
    				$('#mainDiv').load("Technical.html");
    		});
    			$('li.palette').click(function() {
    				$('#mainDiv').load("Palette.html");
    		});
    			$('li.contact').click(function() {
    				$('#mainDiv').load("Contact.html");
    		});	
    	});	
    	
    	</script>
    The two things i tried were this:

    Code:
    	                 $('li.home').click(function() {
    				$('#mainDiv').load("Home.html").fadeIn("slow");
    		});
    And

    Code:
    	                 $('li.home').click(function() {
    				$('#mainDiv').load("Home.html");
                                    fadeIn("slow")
    		});
    Im still learning the syntax properly
    hopefully someone can help

    Thanks in advance

  2. #2
    Join Date
    Mar 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi mate ill leave a simple code

    In your Body:
    <ul id="nav">
    <li><a href="home.php">Go to home</a></li>
    <li><a href="hello.php">Contact Me</a></li>
    <li><a href="portafolio.php">My Work</a></li>
    </ul>

    After your JQuery file:
    <script type="text/javascript">
    $(document).ready(function(){
    $("#nav a").each(function(){ // Where the function must work on
    var href = $(this).attr("href");
    $(this).click(function(){
    $("#show").hide().load(href).fadeIn("slow"); //A Nice Fadein Effect
    $(this).attr({ href: "#"}); //#show is the Div who loads the content
    });
    });
    });
    </script>
    I hope it helps.
    Cheers.
    Last edited by vinnie; 03-29-2010 at 12:21 AM. Reason: More cute version :D

  3. #3
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Customization :)

    Hi,
    i've found Your code through google search and i find very easy and well working
    I'm a noob in jquerry stuff, and i'm using ready to go scripts.
    I'have a question, is there a way to combine Yours script with another?

    I'd like to add this script: http://jscrollpane.kelvinluck.com/ which changes the look of scrollbars to Yours, wchich loads pages nicely

    I think that Your script shuold call the other script at some moment, but i don't know when I tried to put
    Code:
    $('.tresc').jScrollPane();
    in Your script, but it doesn't work

    '.tresc' is my class for div that shows content.

    Is there any way to combine them?

    Thanks.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •