Answer the question
In order to leave comments, you need to log in
How to check the active page using JS?
I tried to make a navigation menu using JS, but the script does not want to work.
In Js, so far, a complete zero.
<div class="header">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".menu li a").each(function() {
if ($(this).attr("href") == location.href) {
$(this).addClass("selected");
}
})
});
</script>
<style>
.selected {
color: #fff;
}
</style>
<ul class="menu">
<li><a href="/">Главная</a></li>
<li><a href="inf.html">О нас</a></li>
<li><a href="photo.html">Фотогалерея</a></li>
<div class="l1"></div>
</ul>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question