Get text from anchor tag

后端 未结 2 1224
死守一世寂寞
死守一世寂寞 2020-12-24 05:51

I have the following anchor tag

Google

I know how to get the href from an anchor take:

2条回答
  •  抹茶落季
    2020-12-24 06:06

    Use .text() for this:

    alert($(this).text());
    

    If you wanted the markup (.text() removes tags and such), use .html()

    alert($(this).html());
    

    In this case there's no difference, if instead you had this:

    Google (External)
    

    Then there would be:

    $(this).text() //"Google (External)"
    $(this).html() //"Google (External)"
    

提交回复
热议问题