Currently working on enhancing website accessibility. I have identified a close menu button that lacks an Aria Label, and my goal is to rectify this using JavaScript.
Although I am utilizing the script below to target the specific ID and add the attribute, the aria label does not seem to be appended upon script execution:
<script>
function addAriaLabel() {
// Create an aria label attribute:
const addAria = document.createAttribute("aria-label");
// Set the value of the aria-label attribute:
addAria.value = "close button";
// Add the href attribute to an element:
document.getElementById("cart-accessibility").setAttributeNode(addAria);
}
</script>
If needed, you can find the element in question at (the filters closing button).
Seeking advice on how to correct this issue - what step am I overlooking?