Search code examples
javascriptjqueryhtmlgetelementbyidwai-aria

How to add aria-hidden property to span on focus change?


I have to change the span element aria-hidden value to "true" on focus change event. How can I do that?

Here is my span element declaration-

<span id="jawshide">#someText</span>

and here is javascript part-

document.getElementById('jawshide').innerHTML= "aria-hidden='true'";

What is the correct way to add this property?


Solution

  • You can do this using setAttribute

    document.getElementById('jawshide').setAttribute('aria-hidden', 'true');