I have pages in my 'inc' folder, when I hit the 'trigger', #wrapper will load the selected page into the #wrapper. The problem I have is;
Whenever I click on 'trigger' outside of the #wrapper it works. And the content will load into the #wrapper. But when I have the 'trigger' inside of the #wrapper it won't work.
I'm stuck on this for a while.
The JS code:
$(document).ready(function() {
// Initial
$('#wrapper').load('inc/home.php');
});
$(document).ready(function() {
// Set trigger and container variables
var trigger = $('#test a'),
container = $('#wrapper');
// Fire on click
trigger.click(function() {
var target = $(this).attr('href');
// Begin fade
setTimeout(function(){ $('#wrapper').css("opacity", "0"); }, 0);
// Load target page into container
setTimeout(function(){ container.load('inc/' + target + '.php'); }, 400);
// End fade
setTimeout(function(){ $('#wrapper').css("opacity", "1"); }, 900);
// Stop normal link behavior
return false;
});
});