Reputation: 9
all.
I'm no programmer (and don't have access to one) and have been asked to automatically expand an aria control on a webpage.
We have very little control over the code (just basic javascript and css) as it's hosted by Okta, and all the examples I've looked at here are baffling to me. Here's what the source for the section looks like:
<a href="#" data-se="needhelp" aria-expanded="false" aria-controls="help-links-container" class="link help js-help">
Bunch of text here that contains a list.
</a>
How I can expand the aria on page load.
Upvotes: 0
Views: 3092
Reputation: 334
Here is the code:
<html>
<head></head>
<body>
<a
id="link-list"
href="#"
data-se="needhelp"
aria-expanded="false"
aria-controls="help-links-container"
class="link help js-help"
>Bunch of text here that contains a list.</a
>
<script type="text/javascript">
window.onload = function () {
var linkList = document.getElementById("link-list");
linkList.setAttribute("aria-expanded", "true");
};
</script>
</body>
</html>
Upvotes: 1
Reputation: 333
Try:
document.getElementsByClassName("link help js-help").setAttribute("aria-expanded", "true");
Upvotes: 1