This is great for adding something like the aria-expanded attribute for menus which expand out. It should work very similar to the ‘toggle’ function jQuery has for toggling a class.


$('#clicked-element').on('click', function() {
$('#element').attr('aria-expanded', function (i, attr) {
    return attr == 'true' ? 'false' : 'true';
  	}); 
});

Leave a Reply