我想学习 jQuery。在我看来,jQuery 只需选择您想要的元素,然后对其进行处理。但是选择方式接近CSS选择器。而且我对CSS css selector不熟悉,因为我一直认为它很不系统,我找不到任何规则。
我对 CSS 选择器的了解如下:
#id
.class
所以我想知道在使用 CSS/jQuery 选择器时有什么规则吗?
更新:
你们能给我解释一下吗,我不明白这个:
In CSS 2.1, style is normally attached to an element based on its position in the document tree. This simple model is sufficient for many cases, but some common publishing scenarios may not be possible due to the structure of the document tree. For instance, in HTML 4 (see [HTML4]), no element refers to the first line of a paragraph, and therefore no simple CSS selector may refer to it.
好像是引入“伪元素伪类”的原因,但具体是什么意思呢?如何理解“没有元素引用段落的第一行,因此没有简单的 CSS 选择器可以引用它”?
最佳答案
jQuery API 站点有几个教程只是选择器,take a look here - 它是 the "getting started" tutorial here 的一部分.
规则是使用正确的selector对于您想选择的内容……除此之外,这取决于您要选择的内容;上面的第一个链接将帮助您了解哪些选择器可以做什么以及何时使用它们。
还要澄清一下,有很多selectors 不是 CSS 选择器,它们是 jQuery 特定的添加,例如 form selectors , basic filter selectors , visibility selectors , 和 content filter selectors .
关于jquery - 学习 jQuery 的 CSS 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4421891/