少し問題があります。アニメーションは、最初にクリックすると動作し、2 回目にクリックすると動作を拒否します。コード:
var main_container = $('.main_container'),
menu = $('.home_navigation_text'),
second_page = main_container.find('.second_page'),
body_width = $(window).width();
menu.hover(
function(){
var $this = $(this),
page = $this.find('a').attr('href');
second_page.empty().load(page);
},
function(){
}
);
menu.on('click', function(e){
main_container.animate({
right: '+=' + body_width
}, 600, 'linear', function() {
go_back();
});
return false;
});
function go_back()
{
var back = second_page.find('.back');
back.on('click', function(e){
main_container.animate({
left: '+=' + body_width
}, 600, 'linear', function() {
});
return false;
});
}
HTML コード:
<div class="main_container clearfix">
<section class="home_page clearfix">
<header class="home_header container">
<div class="grid_3 alpha omega" id="home_logo">
<img class="" src="<?php echo IMG ?>resources/jbs_cc_logo.png" alt="JBS Logo">
</div>
<div class="grid_9 alpha omega">
</div>
</header>
<!-- END OF HEADER -->
<div class="home_main container">
<nav class="home_navigation clearfix">
<ul class="clearfix">
<?php foreach ($menu as $mn): ?>
<li class="home_navigation_text">
<a class=home_navigation_link href="<?php echo base_url($mn['slug']) ?>"><?php echo $mn['title'] ?></a>
</li>
<?php endforeach ?>
</ul>
</nav>
</div>
</section>
<section class="second_page">
</section>
</div>