【问题标题】:<a> click="" does not works with tabindex='0'<a> click="" 不适用于 tabindex='0'
【发布时间】:2021-01-22 00:29:50
【问题描述】:

这是我的代码。

在没有 tabindex 的情况下单击可以工作,但是当我添加 tabindex='0' 并在元素获得焦点时按 Enter 时,它不起作用。

给我打电话

【问题讨论】:

    标签: html angular click


    【解决方案1】:

    1-你应该使用(onclick)而不是(click),使用(onclick)不带括号。 2-添加结束标签。

    &lt;a type='button' role='button' class='primary-link' tabindex='0' onclick='callMe()'&gt;Call me&lt;/a&gt;

    3-最好使用按钮标签。

    &lt;button class='primary-link' tabindex='0' onclick='callMe()'&gt;Call me&lt;/button&gt;

    【讨论】:

    • 抱歉,Ramy,但这在 Angular 应用程序的上下文中是根本错误的。
    猜你喜欢
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 2015-08-24
    • 1970-01-01
    相关资源
    最近更新 更多