[英]how can I add links to my nav bar in javascript?
I am pretty new to javascript.我对 javascript 很陌生。 I am trying to add a link (Section 1) to my nav bar and I am not sure why I still can't see it in the preview.
我正在尝试将链接(第 1 节)添加到我的导航栏,但我不确定为什么我仍然无法在预览中看到它。
var link = document.createElement('a');
link.classList.add('menu__link');
link.href = '#section1';
link.textContent = 'Section 1';
document.getElementById('navbar__list').appendChild(link);
in the second line of your code 'l' letter of 'link' word is missing.在您的代码的第二行中,缺少“链接”字的“l”字母。
var link = document.createElement('a'); link.classList.add('menu__link'); link.href = '#section1'; link.textContent = 'Section 1'; document.getElementById('navbar__list').appendChild(link);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.