W
W
wanderbit2016-09-14 15:46:11
Bootstrap
wanderbit, 2016-09-14 15:46:11

How to remove the scro before the block with an active tab when following an external link?

link ob-avtoshkole/#kollectiv, when you click on it from another page, you need a tab and the screen scrolls to the active tab. How to fix the screen position at the top?

<ul class="nav nav-tabs">
  <li class="active"><a data-toggle="tab" href="#about">об автошколе</a></li>
  <li><a data-toggle="tab" href="#kollectiv">коллектив</a></li>
  <li><a data-toggle="tab" href="#documents">документы автошколы</a></li>
  <li><a data-toggle="tab" href="#gallery">галерея</a></li>
  <li><a data-toggle="tab" href="#direktor">написать директору</a></li>
</ul>
<div class="tab-content">
  <div id="about" class="tab-pane active"></div>
  <div id="kollectiv" class="tab-pane"></div>
  <div id="documents" class="tab-pane"></div>
  <div id="gallery" class="tab-pane"></div>
  <div id="direktor" class="tab-pane"></div>
</div>

var hash = window.location.hash;
if(hash){
  $('html, body').animate({scrollTop:0}, 'fast'); 
  $('.nav.tabs a[href="' + hash + '"]').tab('show');
   
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question