开发者

jquery name$= or name=

开发者 https://www.devze.com 2023-01-15 06:53 出处:网络
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:

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 "$" o开发者_如何转开发ut 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!


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

Attribute Selectors


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


$= is the "attribute ends with" selector.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消