Reputation: 4814
I am trying to focus on header or first div which is inside of accordion but it is not working.
In the js fiddle by default, HTML is active and it consists of 11 questions in it. And now PHP by default it is collapsed and when we click on it, it will open and HTML will collapse.
My problem is when I click on PHP it is showing the last question in my case it is showing the 11th question of PHP, Actually it should show the first question of PHP how can I achieve it..?
Please see the js fiddle which I have shared.
$("#panelForPHP").click(function(){ $("#accordionPHP").focus(); });
$("#panelForPHP").click(function(){ $("#collapsePHP1").focus(); });
$("#panelForPHP").click(function(){ $("#panelForPHP").focus(); });
i have tried with 3 different ways but none are working:
Upvotes: 2
Views: 124
Reputation: 31
Try with this
$('#accordionMain').on('shown.bs.collapse', function() {
var panel = $(this).find('.in');
$('html, body').animate({
scrollTop: panel.offset().top -55
});
});
Upvotes: 1