hey guys so im kinda stumped. i have a menu bar


for example if im on the home page i would like the |home| to be active or to show that i am on the home page. ive tried :visited and i even tried jquery and it doesnt work for me. i dunno, maybe im not doing it right or smtg.

<div class="top-menu-content">
    <ul class="top-menu-button">
        <li class="top"><a class="top-button" href="home.php">Home</a></li>
        <li class="top"><a class="top-button" href="event.php">Events</a></li>
        <li class="top"><a class="top-button" href="contact_data.php">Contacts</a></li>

jquery that i tried:

$(document).ready(function() {
    $(".top [href]").each(function() {
    if (this.href == window.location.href) {



thanks in advance!

Recommended Answers

All 2 Replies

The problem with if (this.href == window.location.href) is that this.href only contains home.php while window.location.href contains the full URL.

oh, then how would i make it for all the href?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.