W
W
WebforSelf2021-07-07 10:01:01
JavaScript
WebforSelf, 2021-07-07 10:01:01

How to build up to multiple anchors inside accordeon bootstrap 4?

I sketched an example. There are links above that lead to anchors.
Anchors, in turn, are in the accordion (tabs).
Accordingly, when you click on the link, the accordion we need opens and scrolls to the link.
When there is only one anchor, then we can find it without problems, but how can we make it possible to place several anchors in a tab? and so that when you click the desired one, it scrolls exactly to it and not to the first anchor.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DivineDraft, 2021-07-07
@WebforSelf

The problem arises because the script specifies scrolling to the "anchor" class, which it finds in an open container, finding the first one found, it stops, which is quite logical. It is required to specify a specific one corresponding to your button.
The decision follows from the court - to find out the value of the link and then pass it to the search method in the container. Since you have a script for opening / closing there, we do not touch these actions and work only with scrolling, you can write a crutch that will find the desired anchor, for example:

ps if you use the entire internal script only for this accordion, then it is better to rewrite it yourself, it will come out in a maximum of 30 lines, and it will work many times better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question