仅使用jquery过滤http://

X10*_*0nD 0 jquery

我有大约400个链接,即,div中的http://.我想只过滤链接(http://)

$("a[href$='']").each(function() {
        $(this).append('#only_http').attr('href');
    });
Run Code Online (Sandbox Code Playgroud)

谢谢让

dec*_*eze 5

$("a[href^='http://']").each(function() {
    $(this).append('#only_http').attr('href');
});
Run Code Online (Sandbox Code Playgroud)

这将选择包含文本 "http://"的所有元素:

$(":contains('http://')")
Run Code Online (Sandbox Code Playgroud)

如果超出此范围,您有兴趣在元素中查找实际文本,请将其与正则表达式匹配,如下所示:

$(this).text().match(/http:\/\/\S+/) // very simple, probably not too reliable
Run Code Online (Sandbox Code Playgroud)

事后我不知道你想做什么...