I'm trying to make jQuery menu, which can highlight current page. Method is, add class current
on selected.
Here is html:
<div class="menu_items">
<ul class="ul_items" id="navigation">
<li><a href="index.php">1</a></li>
<li><a href="index.php?pg=2">2</a></li>
<li><a href="index.php?pg=3">3</a></li>
<li><a href="index.php?pg=4">4</a></li>
<li><a href="index.php?pg=5">5</a></li>
</ul>
</div>
And I tried to make something like that:
$(document).ready(function(){
$("#navigation").find("a[href*='"+window.location.href+"']").each(function(){
$(this).addClass("current")
});
});
Because CSS code is large and etc, complete codes are at jsFiddle
I think that something isn't properly defined in Jquery part of code. When I try this:
var a = $("#navigation").find("a[href*='"+window.location.href+"']");
alert(a);
I get [Object] [Object] alert. Can someone help?
Thanks in advance.