E
E
Erosanteros2015-09-22 15:25:10
css
Erosanteros, 2015-09-22 15:25:10

Is there a trick to make a specific tab(s)(tab$) active when the browser opens a specific address .html#tab$?

There is an HTML page. The main content is placed in tabs, which are implemented through anchors and links to these anchors. With the help of JS, by clicking on the links, they add and remove the active class, which is assigned styles for the active tab in CSS. When saving a page in favorites or directly accessing a
certain section of the page ending in .html#tab$, the current tab is not active because there was no click. Is there a trick to make it active during a direct entry to a certain section of the village.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Inchin ☢, 2015-09-22
@In4in

Something in recent days, too many people interested in the hash ....

var lH = location.hash; //#tab$
//Ну и что-то с этим делайте

A
Anton, 2015-09-22
@karminski

If you are using bootstrap and jquery you can do this:

var hash = document.location.hash;
$('.nav-tabs a[href=#' + hash + ']').tab('show');

D
Dmitry Pyrkin, 2015-09-22
@ps1panda

window.location.href chop off the desired piece after .html and look for the desired selector

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question