i've created a function to get the pathname of the webpage and if it matches the id of the menu item then it will add a css property to the div tag, showing the div as current page. heres the website im testing on: http://kwp.host22.com. im using alerts to check that variables are correct. heres my html.
<div id="navigation">
<a href="index.html"><div class="navblocks" id="index.html"><p>Home</p></div></a>
<a href="cleaning.html"><div class="navblocks" id="cleaning.html"><p>Cleaning</p></div></a>
<a href="contact.html"><div class="navblocks" id="contact.html"><p>Contact Us</p></div></a>
</div>
and heres my jquery:
var path = window.location.pathname;
if(path === "/")
{
var pathname = path.replace("/","index.html");
}
else
{
pathname = path.replace("/","");
}
alert("pathname = " + pathname);
var id = "#" + pathname;
alert("id = " + id);
$('a').each(function()
{
var href = $(this).attr("href");
alert("href = " + href);
if (href === pathname)
{
$(id).css('box-shadow','0px 0px 20px inset');
}
but its not applying the box shadow to the div tag.
any help would be appreciated im still learning jquery. thanks
