now, this is ugly, how do I put them together in 1 row
function side1() {
document.getElementById('side-open1').classList.remove('side-open-dpn');
document.getElementById('item-link1').classList.add('side-open-dpn');
document.getElementById('item-link2').classList.add('side-open-dpn');
document.getElementById('item-link3').classList.add('side-open-dpn');
document.getElementById('item-link4').classList.add('side-open-dpn');
document.getElementById('item-link5').classList.add('side-open-dpn');
}
function back1() {
document.getElementById('side-open1').classList.add('side-open-dpn');
document.getElementById('item-link1').classList.remove('side-open-dpn');
document.getElementById('item-link2').classList.remove('side-open-dpn');
document.getElementById('item-link3').classList.remove('side-open-dpn');
document.getElementById('item-link4').classList.remove('side-open-dpn');
document.getElementById('item-link5').classList.remove('side-open-dpn');
}
i want the item-link(1;5) to be selected together, tried querlySelectroAll too, but maybe i did someting wrong
You can pick them with their ids, sice all of their ids starts with item-link, you can use document.querySelectorAll("[id^='item-link']")
"[id^='item-link']" will select all elements whose id starts with item-link
const nodes = document.querySelectorAll("[id^='item-link']");
console.log(nodes);
<div id="item-link1"></div>
<div id="item-link2"></div>
<div id="item-link3"></div>
<div id="item-link4"></div>
<div id="item-link5"></div>