admin管理员组文章数量:1398840
What should be the value of the role attribute when I apply onclick to a div. I read the documentation WAI-ARIA Roles, but not able to find any specific role value of a div. I am working in React and this ponent is inside a loop, on this ponent I have to go to another page when clicking on this ponent. What should be the value of the role attribute, If I do not use the role attribute then ES-Lint gives me a warning which is not acceptable.
What should be the value of the role attribute when I apply onclick to a div. I read the documentation WAI-ARIA Roles, but not able to find any specific role value of a div. I am working in React and this ponent is inside a loop, on this ponent I have to go to another page when clicking on this ponent. What should be the value of the role attribute, If I do not use the role attribute then ES-Lint gives me a warning which is not acceptable.
Share Improve this question edited Jul 8, 2021 at 13:19 Tushar Shahi 21k2 gold badges23 silver badges46 bronze badges asked Jul 8, 2021 at 13:18 Zeeshan SafdarZeeshan Safdar 4671 gold badge5 silver badges15 bronze badges2 Answers
Reset to default 5On rereading your question, EDIT: since you are performing a navigation : role ="link"
.
For actions, you need role="button"
But, try to use the correct semantic whenever possible.
As it goes to another page - role="link"
as it is effectively a hyperlink (<a>
)
However if you have your routing set up correctly just swap your <div>
for an anchor <a>
and set the href
attribute to the target.
With that being said role="link"
has good support so you should be fine with that.
Also consider that if this is a <div>
then you need to add tabindex="0"
to it so it can be focused with a keyboard and also handle the Enter and Space keys being pressed to also activate the link.
Much easier to use an <a>
element from the start as you can imagine!
本文标签: javascriptWhat should be role value of div in html after apply onclick on divStack Overflow
版权声明:本文标题:javascript - What should be role value of div in html after apply onclick on div - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744124324a2591885.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论