views:

24

answers:

1

You guys already helped me on correctly parsing the REL attribute on A tags, but there are two XFN values that I'm not able to match: "co-worker" and "co-resident". The hyphen causes an error with jquery.

I tried this

xfn_co-worker = $("a[rel~='co-worker']").length;

and this

xfn_co-worker = $("a[rel~='co\-worker']").length;

In both cases the error "Uncaught ReferenceError: Invalid left-hand side in assignment" is returned. (Being these standard XFN values, I'm forces to use them)

Any idea is appreciated, as usual :-)

+4  A: 

This isn't an error in you selector. The error lies in your variable name.

You can't use mathematical operators in the variable name. So the problem is your use of the - sign.

Try replacing

xfn_co-worker

with e.g

xfn_co_worker

And it should work alright

xfn_co_worker = $("a[rel~='co-worker']").length;

Note: Your variable name must match the following regex [a-zA-Z_$][0-9a-zA-Z_$]*

jitter
So my problem was on understanding the error message ...I'm so ashamed for posting such a question, I was too worried about the jQuery selector that wasn't paying attention to the JS basics...Thanks a lot.
UVL
no problem. It happens to everyone that we cannot see the forest for the trees ;)
jitter