filter only http:// using jquery
I have about 400 links, ie., http:// in a div. I want开发者_C百科 to filter only the links ( http:// )
$("a[href$='']").each(function() {
$(this).append('#only_http').attr('href');
});
Thanks Jean
$("a[href^='http://']").each(function() {
$(this).append('#only_http').attr('href');
});
This will select all elements that contain the text 'http://':
$(":contains('http://')")
If beyond that you're interested in finding the actual text within the element, match it with a Regex like this:
$(this).text().match(/http:\/\/\S+/) // very simple, probably not too reliable
I don't know what you want to do with this afterwards...
........
$('a[href^="http://"]')..............more code
so,the answers you received by now are good, meaning they told you how to select what you want. and that fact that you say it is not working amazes me, but still
here you are a proof that it actually works. (just hit Run)
http://jsfiddle.net/4Pzya/link text
and then copy paste what you need although i think you could have done it yourself
精彩评论