学习jQuery的CSS选择器 [英] Learning CSS selectors for jQuery

查看:89
本文介绍了学习jQuery的CSS选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想学习jQuery。在我看来,jQuery只是选择你想要的元素,然后做一些事情。然而,选择方式接近CSS选择器。我不熟悉CSS CSS选择器,因为我一直认为它是非系统性的,我找不到任何规则。

I want to learn jQuery. In my opinion jQuery just select the element you want and then do something on it. However the select manner is close to CSS selector. And I am not familiar CSS css selector since I always think it is rather unsystematic, I can not find any rules.

我所知道的CSS选择器如下:

All I know about the CSS selector is the following:

#id
.class

所以我不知道在使用CSS / jQuery选择器时有什么规则吗?

So I wonder there is any rule when using CSS/jQuery selector?

UPDATE:

你可以给我一个解释,我不明白这一点:

can you guys give me an explaination,I can not understand this:


在CSS 2.1中,样式通常附加
到基于它在
文档树中的位置的元素。这个简单模型
在许多情况下是足够的,但是由于
文档树的结构,一些
通用发布方案可能不是
。例如,在HTML 4
(参见[HTML4])中,没有元素引用
的段落的第一行,而
因此没有简单的CSS选择器
引用它。

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选择器可以引用它

Seems like it is the reason for "Pseudo-elements and pseudo-classes" imported,but what is the exactly meaning? How to understand "no element refers to the first line of a paragraph, and therefore no simple CSS selector may refer to it"?

推荐答案

jQuery API网站为选择器提供了几个教程,看看这里 - 它是入门教程的一部分

The jQuery API site has several tutorials just for selectors, take a look here - and it's part of the "getting started" tutorial here.

规则是使用正确的选择器您要选择的内容...除此之外,它取决于您要选择的内容;上面的第一个链接将帮助选择器做什么,什么时候使用它们。

The rules are to use the correct selector for what you want to select...beyond that it depends on what you're trying to select; the first link above will help with which selectors do what, and when to use them.

还有很多选择器 不是 CSS选择器,它们是jQuery特定的添加项,例如表单选择器基本过滤器选择器公开程度选择器内容过滤器选择器

Also to clarify, there are many selectors that aren't CSS selectors, they're jQuery specific additions, like the form selectors, basic filter selectors, visibility selectors, and content filter selectors.

这篇关于学习jQuery的CSS选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆