jQuery href属性以/ {tag_开头

Tar*_*ine 2 jquery hyperlink

我需要删除文档中以"/ {tag_"或"{tag_"开头的所有链接

到目前为止,我有,$("a[href^='/{tag_']").remove();但它没有工作,

我也有

   $("a").each(function() {
                var href = $(this).attr("href");
                if(href == '') { // or anything else you want to remove...
                    $(this).remove();

                }
                $("a[href^='/{tag_']").remove();
            });
Run Code Online (Sandbox Code Playgroud)

我也尝试过$(this).attr("href^='/{tag_'");不工作,有什么想法吗?

谢谢塔拉

Bar*_*der 6

$('a').each(function() {
  $("a[href^='/{tag_']").remove();
});
Run Code Online (Sandbox Code Playgroud)

这对我有用:http://jsfiddle.net/neuroflux/tKapr/1/

  • 循环有点多余,不是吗?无论如何,remove()都可以在整个选定对象集上运行. (2认同)