I have this code:
<a onclick="$('a[href=\'#tab-customtab\']').trigger('click');">Enquire Now</a>
<div id="tab-customtab"></div>
This opens up the div #tab-customtab but does not scroll to it. Is there a way to scroll to the div onclick?
I have this code:
<a onclick="$('a[href=\'#tab-customtab\']').trigger('click');">Enquire Now</a>
<div id="tab-customtab"></div>
This opens up the div #tab-customtab but does not scroll to it. Is there a way to scroll to the div onclick?
 
    
     
    
    something like this?
function scrollToId(aid){
    var aTag = $("div[id='"+ aid +"']");
    $('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
Try this, it makes you more reliable and dynamic.
$(document).ready(function() {
   $(".menu").on("click",function(event) {
    
   if ($(".toggleMenu").hasClass('active')) {
   
    $(".toggleMenu").click();
   }
   $('html,body').animate({ 
   scrollTop: $(this.hash).offset().top}, 500);
   
   });
            
   $(".chosen-select").chosen();
         
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<header>
  <nav>
    <ul>
        <li> <a href="#div1" class="menu">First</a></li>
        
        <li> <a href="#div2" class="menu">Second</a></li>
        
        <li> <a href="#div3" class="menu">Third</a></li>
        
        <li> <a href="#div4" class="menu">Forth</a></li>
    </ul>
  </nav>
</header>
<section style="height:150px;width:100%;" id="div1">
    <h2 style="text-center">First Div</h2>    
</section>
<section style="height:150px;width:100%;" id="div2">
    <h2 style="text-center">Second Div</h2>
</section>
<section style="height:150px;width:100%;" id="div3">
    <h2 style="text-center">Third Div</h2>
</section>
<section style="height:150px;width:100%;" id="div4">
    <h2 style="text-center">Forth Div</h2>
</section>