ini.php
/ local
$site_url = $_SERVER['DOCUMENT_ROOT'] . '/';
$webroot = '/';
$current = '';
header.php
<nav id="global-nav"><nav id="global-nav"> <ul id="navi_list"> <li class="<?php echo $current == 'top' ? 'select':'' ?>"><a href="<?php echo $webroot; ?>">ホーム</a></li> <li class="<?php echo $current == 'service' ? 'select':'' ?>"><a href="<?php echo $webroot; ?>service/index.php">事業内容</a></li> <li class="<?php echo $current == 'product' ? 'select':'' ?>"><a href="<?php echo $webroot; ?>product/index.php">商品情報</a></li> <li class="<?php echo $current == 'kit' ? 'select':'' ?>"><a href="<?php echo $webroot; ?>">キット</a></li> <li class="<?php echo $current == 'faq' ? 'select':'' ?>"><a href="<?php echo $webroot; ?>faq/index.php">よくある質問</a></li> <li class="<?php echo $current == 'news' ? 'select':'' ?>"><a href="<?php echo $webroot; ?>news/index.php">お知らせ</a></li> <li class="<?php echo $current == 'info' ? 'select':'' ?>" class="red"><a href="<?php echo $webroot; ?>">お問い合わせ</a></li> </ul> </nav>
script
<script><script> $( function () { $( '#navi_list li a' ).on( 'click', function () { $( this ).parent('li').addClass( 'select' ).siblings( 'li.select' ).removeClass( 'select' ); } ); } ); </script>
inex.php他第2階層のページ
カレントページがどこかを教えてあげる、、、
<!-------------------------------------------------------------<!-------------------------------------------------------------header--------------------------------------------------------------> <?php $current = 'top'; include($site_url.'./header.php'); ?>