views:

52

answers:

3

Lets say I have named some elements with the following structure:

  • 1:0
  • 11:0
  • 21:0

When I was looking for the value of 1:0 I found that the following code returned everything with a 1:0 in it:

alert($("[name$=" + arrayVal[i] + "]").val());

However when I took the "$" out it appears to only return the 1:0 in my above example. I did a quick search on Google but couldn't find anything to support this finding. Does anyone have any links they could point me to for this?

Thanks!

+1  A: 

In jQuery, $= means 'ends with', and = means 'is equal to'.

Attribute Selectors

Rocket
That's awesome. Do you have any links to support that? I couldn't find any.
Jeff V
http://api.jquery.com/attribute-ends-with-selector
Rocket
+1  A: 

The $= is the attribute ends-with selector, so what you got was the expected behavior.

For a full read, whch seems to be what you're after, you can find all of the attribute selectors here.

When in doubt, go to the source, the jQuery API Site, a quick search will answer most of your "what's this operator?" questions :)

Nick Craver
@Nick - Thanks. I have made that site a favorite.
Jeff V
+1  A: 

$= is the "attribute ends with" selector.

http://api.jquery.com/category/selectors/

James Curran