js set attribute aria-expanded code example Example: js set attribute aria-expanded document.getElementById(id2).setAttribute('aria-expanded', 'true');