I'm trying to filter the XFN relationships meta data found in web pages. It is something like this:
<a href="site" rel="friend colleague" >Name</a>
in REL you can have various values, like "friend", "collegue" but even "me" and "met" because you can have multiple values, I did this:
xfn_me = $("a[rel*=me]").length;
But this doesn't work, because both "me" and "met" are matched! Is there a way to filter the values exactly, even when there are multiple values?
Thank you.
Please note that I have no control on the page, in fact I'm working on a Chrome extension, and this code should runs on any web page.
You could use the [attribute~=value]
selector. It selects based on space-separated values exactly like how xfn and CSS classes work, i.e. [class~=className]
is exactly the same as .className
.
xfn_me = $("a[rel~=me]").length;
I couldn't find it in the jQuery documentation, but it works in 1.3 at least.