How do I change the two word attribute in html with JavaScript? Example: There is an example HTML page:
<!DOCTYPE html>
<html>
<head>
<script src="randomscript.js"></script>
</head>
<body>
<h1 id="mywords" aria-label="Yellow">Words</h1>
</body>
</html>
Note: aria-label
can be changed to any two word attribute (separated by dash) that fits in that context.
Now, moving on to the JS
document.querySelector("#mywords h1").aria-label = "Blue";
But that doesn't seem to work, as the aria-label
is still Yellow
!
How might I do this? Thanks.
EDIT: According to my text editor, the aria
turns blue, the -
turns red, but the label
stays white. This suggests that the dash or what's after the dash is causing the problem.