JQuery属性操作

TTC*_*TCG 2 jquery attributes

当我在互联网上搜索JQuery时,我得到了jquery备忘单.在那里,我对如何使用以下条件下的以下内容感到非常困惑.请帮助我.

[attribute|=val]
[attribute*=val]
[attribute~=val]
[attribute$=val]
[attribute=val]
[attribute!=val]
[attribute^=val]
[attribute]
[attribute1=val1] [attribute2=val2]
Run Code Online (Sandbox Code Playgroud)

这些特殊字符*,〜,$,!,^的功能是什么?非常感谢.

cle*_*tus 5

请参阅属性选择器:

你的最后一个例子可能意味着两件事中的一件,取决于它之间是否有空格:

  • [attr1=foo][attr2=bar]表示查找attr1具有值foo attr2值的属性的元素bar; 但

  • [attr1=foo] [attr2=bar]表示查找具有属性attr1值的元素,该属性具有带有值的属性的foo 后代.attr2bar

这里的空间在表达中产生了重要的语义差异.