webdad3
webdad3

Reputation: 9080

jquery name$= or name=

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

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!

Upvotes: 1

Views: 300

Answers (3)

James Curran
James Curran

Reputation: 103495

$= is the "attribute ends with" selector.

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

Upvotes: 1

Nick Craver
Nick Craver

Reputation: 630379

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 :)

Upvotes: 1

gen_Eric
gen_Eric

Reputation: 227200

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

Attribute Selectors

Upvotes: 1

Related Questions