Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
jQuery + Bootstrap Navigation Bar - How to highlight the link when visited

Please visit this link.

Try to click "Portfolio" link, it should be highlighted with blue background.

But after clicking outside the navigation bar it will be highlighted with blue.

    //scrolling
$('nav a').on('click', function() {

    var scrollAnchor = $(this).attr('data-scroll'),
        scrollPoint = $('section[data-anchor="' + scrollAnchor + '"]').offset().top;

    $('body,html').animate({
        scrollTop: scrollPoint
    }, 500);

    return false;

});

//change color
$(window).scroll(function() {
    var windscroll = $(window).scrollTop();
    if (windscroll) {
        $('section').each(function(i) {
            if ($(this).position().top <= windscroll) {
                $('nav a.active').removeClass('active');
                $('nav a').eq(i).addClass('active');
            }
        });

    }
}).scroll();
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Just like hover there is also visited,where you can assign color for the visted links.

a:visited {
    color: blue;
}
about 4 years ago · Santiago Trujillo Report

0

Try this

nav a.active,
nav a.active:hover {
  background-color: blue !important;
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!