I'm a beginner and encountered an error saying Uncaught TypeError: players.setAttribute is not a function when submitting an action. How can I solve this issue? Please share your insights.
'''
//selecting all necessary elements
const selectBox = document.querySelector(".select-box"),
selectXBnt = selectBox.querySelector(".playerx"),
selectOBnt = selectBox.querySelector(".playero"),
playBoard = document.querySelector(".playboard"),
allBox = document.querySelectorAll("Section span"),
players = document.querySelectorAll(".players");
window.onload = ()=>{//once window load
for (let i = 0; i < allBox.length; i++) {// add onclick attribute in all avaiable section's span
allBox[i].setAttribute("onclick", "clickedBox(this)");
}
selectXBnt.onclick = ()=>{
selectBox.classList.add("hide");//hide the box when click
playBoard.classList.add("show");//show the Playboard after clicking
}
selectOBnt.onclick = ()=>{
selectBox.classList.add("hide");//hide the box when click
playBoard.classList.add("show");//show the Playboard after clicking
players.setAttribute("class", "players active");
}
}
let playerxIcon = "fas fa-times";// class name of fontawesome cross
let playeroIcon = "far fa-circle";// class name of fontawesome circle
function clickedBox(element){
}
'''