Раздел раскрывающегося списка HTML не переместится в раздел href. ⇐ CSS

Разбираемся в CSS
Anonymous
Раздел раскрывающегося списка HTML не переместится в раздел href.

Сообщение Anonymous »


Hi I am trying to set a dropdown that can move to sections specified in herf

here is my initial code

Menu According to this, about should go to the about section and projects to projects as mentioned in herf tags
but the li a are not getting clicks or cannot process them.

I have tried this js below that I took from another stack post - I did change the herf to data-herf when i was attempting this - Yet I could not resolve this.

$(document).ready(function() { $('a[data-href]').click(function(event) { event.preventDefault(); var sectionToNavigate = $(this).attr('data-href'); if(sectionToNavigate && $(sectionToNavigate).length) { $('html, body').animate({ scrollTop: $(sectionToNavigate).offset().top }, 1000); } }); }); I have read other posts which concludes it as a browser issue. But I have tried edge, chrome and brave none seem to be working.


Источник: https://stackoverflow.com/questions/781 ... ef-section

Вернуться в «CSS»