Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
What aria label do I need on an HTML button that changes content using JavaScript and JSON data?

enter image description hereI have a webpage that has some HTML buttons. Clicking on a button will change the pages text and image content via JavaScript. The content is loaded from a JSON file.

  <div class="dot-buttons role="tablist" aria-label="crew list">
    <button role="tab" class="dot-button" aria-selected="true">Douglas Hurley</button>
    <button role="tab" class="dot-button" aria-selected="false">Mark Shuttlewort</button>
    <button role="tab" class="dot-button" aria-selected="false">Victor Glover</button>
    <button role="tab" class="dot-button" aria-selected="false">Anousheh Ansari</button>
  </div>

What I'm confused about is how to markup the ARIA label so the user understands that clicking on the button will change the pages content.

I tried:

aria-controls="Tab-1" 

But this failed my accessibility test since the buttons don't really control other HTML elements. The buttons only change the content within the elements.

How can I set ARIA labels for the buttons so users will understand that clicking on them will change the content?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your sample code is using the tab design pattern. Is that what you want to do? Do you have something on your page that looks something like this:?

enter image description here

If so, then the code you have is sufficient. When the user selects one of the buttons, I presume you toggle aria-selected from "false" to "true" (or vice versa). When you toggle the value, the screen reader will announce the state change automatically. That's one of the benefits of using ARIA attributes - it has built in support for notifying assistive technology such as screen readers about changes.

And since you're using role="tablist", the combination of the user hearing that they have a tablist and that a state toggles from "not selected" to "selected" is enough of a hint to the user that something on the page updated when the button was selected.

And if this is the pattern on your page, you could have aria-controls on your button and it would refer to the ID of the panel it displays, but aria-controls doesn't buy you much from assistive technology support. I think one screen reader (JAWS) does something with it but most of the others don't, so it's not a big deal if you use it or not. Of course, that's sort of a catch-22. If screen readers don't support it, then people won't use it, and if people don't use it, there's no incentive for screen readers to support it. Generally you should use the appropriate ARIA attributes whether there's support for them or not so that you'll be ready when support comes. The tab design pattern mentioned earlier says that you should use aria-controls.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda