admin管理员组文章数量:1355646
Is there any way to get the value of the aria-label using jQuery?
I have this function
$(document).ready(function() {
console.log("dom ready")
$(document).on('click', '.clicker', function(e) {
e.preventDefault();
e.stopPropagation();
var hrefValue = this.href;
var label = this.aria - label;
var id = this.id;
console.log("aria label " + label);
fire(hrefValue)
});
});
Which works if I want to get the hrefValue
from this dropdown:
<a class="dropdown-toggle rootelements clicker" role="button" aria-label="'+elem.appname+'" data-toggle="dropdown" data-toggle="tooltip" title=' + elem.link + ' href="' + elem.value +'"><i style="color:' + elem.iconcolor + ';" class="' + elem.icon + '" id="jsonicon"></i></a>
But this console.log("aria label " +label)
Returns aria label NaN
for me when expected output is debug
Is there any way to get the value of the aria-label using jQuery?
I have this function
$(document).ready(function() {
console.log("dom ready")
$(document).on('click', '.clicker', function(e) {
e.preventDefault();
e.stopPropagation();
var hrefValue = this.href;
var label = this.aria - label;
var id = this.id;
console.log("aria label " + label);
fire(hrefValue)
});
});
Which works if I want to get the hrefValue
from this dropdown:
<a class="dropdown-toggle rootelements clicker" role="button" aria-label="'+elem.appname+'" data-toggle="dropdown" data-toggle="tooltip" title=' + elem.link + ' href="' + elem.value +'"><i style="color:' + elem.iconcolor + ';" class="' + elem.icon + '" id="jsonicon"></i></a>
But this console.log("aria label " +label)
Returns aria label NaN
for me when expected output is debug
2 Answers
Reset to default 6https://api.jquery./attr/
var label = $(this).attr('aria-label');
You can either use camel case or bracket notation since aria-label
contains a hyphen, which makes it not a valid identifier, so it cannot be used in dot notation.
var label = this.ariaLabel;
// or
var label = this['aria-label'];
本文标签: javascriptGet arialabel from html using jqueryStack Overflow
版权声明:本文标题:javascript - Get aria-label from html using jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744028198a2578423.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论