Should aria-expanded attribute take the value true or string "true"?

I am setting the aria-expanded attribute's value with jquery. I am confused whether I should do:

$(".dropdown-toggle").attr("aria-expanded", true);

or

$(".dropdown-toggle").attr("aria-expanded", "true");

Should true be treated as a string or simply a javascript data type?

Answers 1

  • We can use both way to set aria-expanded attribute. Both will set attribute correctly.

    $(".dropdown-toggle").attr("aria-expanded", "true");
    $(".dropdown-toggle").attr("aria-expanded", true);
    

    Normally first option is used but we can use both.


Related Articles