简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM