javascript - 我们如何在 angularjs 中的 select 选项上提供标题?

标签 javascript angularjs title ui-select2

我正在使用 AngularJS。现在我想保留我的 html 选择选项的标题。我怎样才能在那里使用......我的代码在这里。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<select class="col-md-12 hkg-nopadding" ui-select2="{allowClear:     true}" ng-model="name" id="selectName" name="selectName">
                <option value=""></option>
                <option ng-repeat="name in names" value="{{name.id}}" title=
            "{{name.text}}">{{name.text.length > 50 ? name.text.substring(0, 50) + '...' : name.text}}</option>
        </select>

这里的标题标签没有被应用。请帮忙。!

最佳答案

使用aria-label而不是标题属性:

Relying on the title attribute is currently discouraged as many user agents do not expose the attribute in an accessible manner as required by this specification (e.g. requiring a pointing device such as a mouse to cause a tooltip to appear, which excludes keyboard-only users and touch-only users, such as anyone with a modern phone or tablet).

引用文献

关于javascript - 我们如何在 angularjs 中的 select 选项上提供标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29406872/

相关文章:

javascript - 使用 Jquery 强制从外部服务器下载图像

ruby-on-rails - 标题标签在 Rails/HAML 中被转义两次

javascript - 在 for() 循环中声明的 Javascript 变量的范围是什么?

javascript - 如果 URL 哈希发生变化,页面是否会显示不同的内容?

javascript - 请求 header 不是从 Service Worker 发送的

scala - 使用 Lift 更改 &lt;title&gt;

javascript - 从 json 获取标题标签

javascript - 如何在angularjs中提交后隐藏表单

javascript - 禁用卫星弹出窗口标题栏

javascript - AngularJS 确认密码验证