Having some trouble with the getElementById() function not functioning as expected and unable to identify the issue.
This is an excerpt of my HTML body:
<button type="button" id="up">Increase Volume</button>
<button type="button" id="down">Decrease Volume</button>
<script src="final.js"></script>
Contained within my script file is the following code snippet:
const upButton = document.getElementById("up");
const downButton = document.getElementById("up");
initialize();
function initialize(){
upButton.setAttribute("width", "300px");
console.log(upButton.getAttribute("width"));
upButton.setAttribute("left", (Math.floor(Math.random() * 1000)).toString() + "px");
downButton.setAttribute("top", (Math.floor(Math.random() * 1000)).toString() + "px");
downButton.setAttribute("left", (Math.floor(Math.random() * 1000)).toString() + "px");
}