how to change the value of 'ARIA-LABEL` according to user's precise language
getLang(element): void {
let lang = element.document.getElementsByTagName('html')[0].getAttribute('lang');
const labelAria = element.document.querySelector('[aria-label]');
if(lang === 'en'){
?????
}
}
Seeem give me some guidance I will be very grateful
I'm not sure what you mean by element.document but here is the correct way:
const labelAria = document.getElementById('element-id');
// set attribute
if(lang === 'en'){
labelAria.setAttribute('aria-label', 'description here');
}
But if you really want to get the element by its aria label:
const labelAria = document.querySelector('div[aria-label="description here"]');
// set attribute
if(lang === 'en'){
labelAria.setAttribute('aria-label', 'description here');
}