Answer the question
In order to leave comments, you need to log in
How to write a vanilla js script to scroll to blocks?
How to catch a click on a menu item and scroll the page to a block with smooth animation?
I outlined the structure in jsfiddle
PS And tell me where to watch a video or read on such basics in native JS?
Answer the question
In order to leave comments, you need to log in
Try to check if your field is complete before submitting the form using the isComplete() method. isComplete
To scroll to the element, you have already assigned hash tags, it remains to add id to the blocks:
Then the browser itself will scroll to the element.
To catch a click, you need to use the onclick event:
<div class="block block-1" id="block-1" onclick="on_block1_click">
// в скрипте:
function on_block1_click() {
alert("пользователь кликнул на block-1");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question