使用jquery和html字符串查找每个链接

dan*_*ich 2 javascript jquery

我想在这个HTML字符串中找到每个"a"标签

$(document).ready(function(data) {
    $.get('test.html',
        function(responseText){
        //find each a tag   
        }, "html"
    )
});
Run Code Online (Sandbox Code Playgroud)

为什么这对我来说太难了?

jrh*_*ath 7

获取所有链接并使用它们执行某些操作:

$.get('test.html', function(responseText) {
    var $response = $(responseText);
    var $links = $response.find('a');
    $links.each(function(index, $link) {
        // go nuts
    });
});
Run Code Online (Sandbox Code Playgroud)

更多信息,请阅读jQuery文档 - 非常好!