关于<a> title attribute?</a>的jQuery / JavaScript查询

时间:2014-11-17 13:08:31

标签: javascript jquery html

$.get('http://www.roblox.com/', function(data) {
    $(data).find('.member-name-container').children('[title]').each(function() {
        console.log( $(this ).text() );
    });
});

我正试图让它在HTML中找到这段代码的<a title='titlehere'></a>

这是我想要找到的标题;

<div class="member-name-container">
    <a class="notranslate" href="/User.aspx?ID=4681012" title="DeltaAddict">DeltaAddict</a>
</div>

我如何打印出title =“DeltaAddict”?

2 个答案:

答案 0 :(得分:1)

我认为这就是你要找的东西:

$.get('http://www.roblox.com/',function(data){
    $(data).find('.member-name-container a').each(function() {
        console.log( $( this ).attr('title') )
    })
});

答案 1 :(得分:0)

这会给你你想要的东西:

$.get('http://www.roblox.com/',function(data){
$(".member-name-container").children("a").each(function() {
alert($(this).attr( "title" ));
});
});