I need some help from jQuery geeks. this is my HTML code
<div class="activity-accordian activdesti-list">
<div class="activity-box-wrap">
<div id="headerone-hd"></div>
<h3 data-subject="Header One" id="headerone" class="headerone-hd active-header">Header One</h3>
<div id="headerone-wrap" class="categ-content">
...
</div>
</div>
<div class="activity-box-wrap">
<div id="headertwo-hd"></div>
<h3 data-subject="Header Two" id="headertwo" class="headertwo-hd active-header">Header Two</h3>
<div id="headertwo-wrap" class="categ-content">
...
</div>
</div>
<div class="activity-box-wrap">
<div id="headerthree-hd"></div>
<h3 data-subject="Header Three" id="headerthree" class="headerthree-hd active-header">Header Three</h3>
<div id="headerthree-wrap" class="categ-content">
...
</div>
</div>
</div>
This is js code which tried but didn't work
function _scrollTopHead() {
$('.activity-accordian h3').on('click', function(e){
var idName = $(this).attr('id');
$('html, body').animate({scrollTop:$("#"+idName+"-hd").offset().top}, 'slow');
});
}
I need h3 tag header to scroll top when that tag is clicked. (i.e if some one click h3 tag where id="headertwo" that h3 tag should scroll up and position in top of the browser. any help would appriciate
Thanks