jquery 名称$= 或名称=
假设我已经用以下结构命名了一些元素:
- 1:0
- 11:0
- 21:0
当我寻找 1:0 的值时,我发现以下代码返回了其中包含 1:0 的所有内容:
alert($("[name$=" + arrayVal[i] + "]").val());
但是当我把“$”去掉了,在上面的例子中它似乎只返回 1:0。我在谷歌上进行了快速搜索,但找不到任何支持这一发现的内容。有没有人有任何可以向我指出的链接?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 jQuery 中,
$=
表示“结尾为”,=
表示“等于”。属性选择器
In jQuery,
$=
means 'ends with', and=
means 'is equal to'.Attribute Selectors
$=
是属性结尾选择器,所以你得到的是预期的行为。对于完整的阅读,这似乎就是您所追求的,您可以找到所有此处的属性选择器。
如有疑问,请转到源代码 jQuery API 站点,快速搜索将回答大多数问题 你的“这个运算符是什么?”问题 :)
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 :)
$=
是“属性结尾为”选择器。http://api.jquery.com/category/selectors/
$=
is the "attribute ends with" selector.http://api.jquery.com/category/selectors/