Menu icon Foundation

My Posts

No Content

My Comments

Andy Grand commented on David Kavanagh's post over 5 years

You can use some extra jQuery to enable URL access to a specific tab (works for any element within a tab too).

 var idx = document.URL.indexOf("#");
    if (idx != -1) {
        var hash = document.URL.substring(idx + 1);
        $(".tabs").children("dd").each(function() {
            var id = $(this).find("a").attr("href").substring(1);
            var $container = $("#" + id);
            $(this).removeClass("active");
            $container.removeClass("active");
            if (id == hash || $container.find("#" + hash).length) {
                $(this).addClass("active");
                $container.addClass("active");
            }
        });
    }

Posts Followed

  • 15
    Replies
  • foundation 5 tab issues

    By David Kavanagh

    tabsdeep linkingjs

    I'm going to take a chance and mention all my issues in one post. First, my tabs do switch just fine. I got things styled nicely, but... - the URL fragment doesn't reliably change when I select tabs. I thought I would see the #tab1 or #tab2 set in the UR... (continued)

    Last Reply by Andy Grand over 5 years ago


Following

    No Content

Followers

My Posts

No Content

My Comments

You commented on David Kavanagh's post over 5 years

You can use some extra jQuery to enable URL access to a specific tab (works for any element within a tab too).

 var idx = document.URL.indexOf("#");
    if (idx != -1) {
        var hash = document.URL.substring(idx + 1);
        $(".tabs").children("dd").each(function() {
            var id = $(this).find("a").attr("href").substring(1);
            var $container = $("#" + id);
            $(this).removeClass("active");
            $container.removeClass("active");
            if (id == hash || $container.find("#" + hash).length) {
                $(this).addClass("active");
                $container.addClass("active");
            }
        });
    }

Posts Followed


Following

  • No Content

Followers

  • No Content