Changing the CSS of a file included with PHP using JavaScript

Monday, June 30, 2014

I've recently made a site where I have a navigation bar, which is included to the pages using PHP.



<?php include "Assets/Inclusions/NavigationBar.php" ?>


I wanted the active page list item to have bold text, so I used JavaScript to fetch the current path and make the relative element bold with a lot of if statements.



<script>
if(location.pathname == 'location.php')
document.getElementById("location").style.fontWeight="800";
} ...and so on
</script>


Is there a better way I should have done this?







http://ift.tt/1mPcoz3