dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Problem with highlight active link-script

  1. #1
    Join Date
    Jan 2017
    Posts
    1

    Problem with highlight active link-script

    Hi!

    I found this (imo) great script to highlight active links: https://www.youtube.com/watch?v=dRLOHxyCaGU

    The problem is that i have few links that have the same name so they get higlighted both at some point. Here is the JS: http://rego.oulanka.us/~rammst3/script/js/highlight.js

    As you can see there is "Live" under "Galleria (gallery)" and "UKK (faq)" also and so on... Is there any way to fix this? Thanks.

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,257
    It helps if you provide code, the problem area(s) thats highlighted and when posting code blocks, use forum BBCode tags so that its easier to read the code.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Dec 2012
    Posts
    1,495
    https://css-tricks.com/pseudo-class-selectors/
    :contains() - As far as I know, this is gone. The current CSS3 spec has removed it.
    I recommend checking the current URL whether it contains the href attribute of the link like this:
    Code:
    $(".col-md-12").children("a").each(function() {
        if (location.href.indexOf($(this).attr("href")) != -1) {
            $(this).addClass("active");
            $(".navbar-nav").find("a").each(function() {
                if ($(this).text().indexOf("KIERTUE") != -1) $(this).parent().setClass("active");
            })
        }
    })
    (Only a hint, I didn't test it.)
    Last edited by Sempervivum; 01-11-2017 at 12:57 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles