Highlighting the active menu item

/* *------------------------------------------------------------------------------ * @script Highlighting the active menu item *------------------------------------------------------------------------------ * @copyright Copyright (C) 2016 Denius.biz. All Rights Reserved. * @author Denius [get@denius.biz] * @link: http://denius.biz/ *------------------------------------------------------------------------------ */ <!-- Style --> <style type="text/css"> .links .active { border: 1px solid #c3c3c3; color: #c3c3c3; display: block; font-size: 16px; margin: -1px; padding: 3px 20px; text-decoration: none; } </style> <!-- Menu --> <div class="links"> <a href="http://kellerrostov.ru/index.php?route=common/home">Главная</a> <a href="index.php?route=information/sitemap">Каталог</a> <a href="index.php?route=product/testimonial">Отзывы</a> <a href="index.php?route=information/contact">Контакты</a> </div> <!-- Script --> <script type="text/javascript"> var links = document.getElementsByClassName("links"); for (var i = 0; i < links[0].children.length; i++) { if (links[0].children[i].href == document.location.href) { links[0].children[i].className += "active"; // console.log(links[0].children[i]); } } </script>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.