Skip to content

Instantly share code, notes, and snippets.

@zeuxisoo
Created July 10, 2012 15:07
Show Gist options
  • Save zeuxisoo/3083901 to your computer and use it in GitHub Desktop.
Save zeuxisoo/3083901 to your computer and use it in GitHub Desktop.
011_jQuerySite_Modified
!function($) {
$(function() {
var hash = window.location.hash.substr(1);
var href = $('#nav li a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(0,href.length-5)){
var toLoad = hash+'.html #content';
$('#content').load(toLoad)
}
});
$('#nav li a').click(function(){
var target_content = $(this).attr('href')+' #content';
$('#content').hide();
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
$('#content').load(target_content, function() {
$('#content').show();
$('#load').fadeOut('normal');
});
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
return false;
});
});
}(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment