聊聊Jquery中的各種選擇器

2021-10-09 05:04:39 字數 698 閱讀 5759

class中帶空格不是指乙個class,而是指兩種class中的任意一種

在 html 中,乙個 class 值中可能包含乙個詞列表,各個詞之間用空格分隔。例如,如果希望將乙個特定的元素同時標記為重要(important)和警告(warning),就可以寫作:

="important warning"

>

this paragraph is a very important warning.

<

/p>

這兩個詞的順序無關緊要,寫成 warning important 也可以。

我們假設 class 為 important 的所有元素都是粗體,而 class 為 warning 的所有元素為斜體,class 中同時包含 important 和 warning 的所有元素還有乙個銀色的背景 。就可以寫作:

.important 

.warning

.important.warning

如:

1、首先,開啟html編輯器,新建html檔案,例如:index.html,編寫問題基礎**。

2、在index.html中的

JQuery各種選擇器

1 類選擇器 通過 id名 獲取該標籤 定義乙個標籤,id屬性賦值 pid 載入事件 p 通過id獲取該標籤 pid click function 2 類選擇器 通過.class名 獲取該標籤 定義乙個標籤,class屬性賦值 pid 載入事件 p 通過class獲取該標籤 pid click fu...

jQuery 的各種選擇器

this 當前元素 p 所有元素 input 所有input元素 intro 所有 class intro 的元素 p.intro 所有 class intro 的元素 intro id intro 的第乙個元素 ul li ul下的所有li節點 ul li first 每個 的第乙個 元素 hre...

Jquery各種選擇器及作用

過濾選擇器 first last not selector even odd eq index gt index lt index header animated focus 內容過濾選擇器 contains text empty has selector div has p parent 可見性過...