S
S
siza2020-03-11 17:41:19
JavaScript
siza, 2020-03-11 17:41:19

How to scroll elements relative to parent?

There is a block with a fixed width that can be scrolled, it has 5 elements.

There are 5 buttons, is it possible to make the block scroll to the 5th element when you click on the 5th button, for example?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor, 2019-08-03
@polyak-888

document.onclick = function(event){
      if (event.target.tagName === 'A' || event.target.closest('a')) {
         let isLeaving = confirm(`do you want go to ${event.target.closest('a').href} ?`);
         if (!isLeaving) return false;
      }              
    };

A
Alex, 2020-03-11
@Kozack

https://developer.mozilla.org/en/docs/Web/API/Elem...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question