W
W
WebforSelf2021-07-07 00:10:36
JavaScript
WebforSelf, 2021-07-07 00:10:36

How to smoothly scroll to jquery anchor?

There are links with anchors and an accordion with text,

For example, there is an item2 link and in the second tab there is id = item2 How
to make it open the desired tab and scroll to the ID when clicking on the link
there are several anchors in one tab, then the first click will open the tab you need and it will be possible to scroll, but if the person then goes up and clicks another link, then the active tab will simply collapse.

I have no idea how to do this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Dubrovin, 2021-07-07
@alekcena

Since no one answered for several hours.
I'll try.

function test(e){
e.preventDefault();
let IdHref = this.getAttribute('href');
let acc = document.querySelector(idHref).closest("ищем ссылку на ваш акардеон");
console.log(acc);
//Ну и активируем чтоб он открылся попробуйте click(); я хз как работает 
//Надеюсь проблема была в том чтобы найти нужный аккордеон
}
//Далее думаю разберётесь

How to make a smooth page scroll to the anchor?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question