How to add aria-label to nav using jquery

Hey guys, hope you can lend a hand…

I am trying to add role="navigation" aria-label="main navigation" to my main navigation using jquery. All the other code should be intact within the <nav> element.

So this <nav id="ubermenu-top-nav-788" class="ubermenu"> would become <nav id="ubermenu-top-nav-788" class="ubermenu" role="navigation" aria-label="main navigation">.

Can’t seem to find the proper way to do this with jQuery. Thanks in advance, any help is greatly appreciated.

1 Like

Plain Javascript can also accomplish this simply.

document.getElementById(‘ubermenu-top-nav-788’).setAttribute(‘aria-label’, ‘main navigation’);

Or, if you simply must use jQuery, then you would use,

$(‘#ubermenu-top-nav-788’).attr(‘aria-label’, ‘main navigation’);

Nektro

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.