DIV CSS 佈局教程網

jQuery 與 CSS 選擇器全彙總,常備復習
編輯:JQuery特效代碼     

jQuery 選擇器

選擇器實例選取
*$("*")所有元素
#id$("#lastname")id="lastname" 的元素
.class$(".intro")所有 class="intro" 的元素
element$("p")所有 <p> 元素
.class.class$(".intro.demo")同時有 intro 與 demo 兩個 class 的元素
:first$("p:first")第一個 <p> 元素
:last$("p:last")最後一個 <p> 元素
:even$("tr:even")所有偶數 <tr> 元素
:odd$("tr:odd")所有奇數 <tr> 元素
:eq(index)$("ul li:eq(3)")列表中的第四個元素(index 從 0 開始)
:gt(no)$("ul li:gt(3)")index 大於 3 的元素
:lt(no)$("ul li:lt(3)")index 小於 3 的元素
:not(selector)$("input:not(:empty)")所有不為空的 input
:header$(":header")所有標題元素 h1-h6
:animated所有動畫元素
:contains(text)$(":contains('W3School')")包含指定字符串的所有元素
:empty$(":empty")無子節點的所有元素
:hidden$("p:hidden")所有隱藏的 <p>
:visible$("table:visible")所有可見的表格
s1,s2,s3$("th,td,.intro")所有匹配的 th、td 與 .intro
[attribute]$("[href]")所有帶 href 屬性的元素
[attribute=value]$("[href='#']")href 值等於 "#" 的元素
[attribute!=value]$("[href!='#']")href 值不等於 "#" 的元素
[attribute$=value]$("[href$='.jpg']")href 值以 ".jpg" 結尾的元素
:input$(":input")所有 <input> 元素
:text$(":text")所有 type="text" 的 input
:password$(":password")所有 type="password" 的 input
:radio$(":radio")所有 type="radio" 的 input
:checkbox$(":checkbox")所有 type="checkbox" 的 input
:submit$(":submit")所有 type="submit" 的 input
:reset$(":reset")所有 type="reset" 的 input
:button$(":button")所有 type="button" 的 input
:image$(":image")所有 type="image" 的 input
:file$(":file")所有 type="file" 的 input
:enabled$(":enabled")所有激活的 input
:disabled$(":disabled")所有禁用的 input
:selected$(":selected")所有被選取的 input
:checked$(":checked")所有被選中的 input

CSS 選擇器

選擇器例子描述CSS
.class.intro選擇 class="intro" 的所有元素1
#id#firstname選擇 id="firstname" 的元素1
**選擇所有元素2
elementp選擇所有 <p> 元素1
element,elementdiv,p所有 div 和 p1
element elementdiv pdiv 內部的所有 p1
element>elementdiv>p父元素為 div 的所有 p2
element+elementdiv+p緊接在 div 之後的所有 p2
[attribute][target]帶 target 屬性的元素2
[attribute=value][target=_blank]target="_blank" 的元素2
[attribute~=value][title~=flower]title 含單詞 "flower" 的元素2
[attribute|=value][lang|=en]lang 值以 "en" 開頭的元素2
:linka:link所有未被訪問的鏈接1
:visiteda:visited所有已被訪問的鏈接1
:activea:active活動鏈接1
:hovera:hover鼠標懸停的鏈接1
:focusinput:focus獲得焦點的 input2
:first-letterp:first-letter每個 p 的首字母1
:first-linep:first-line每個 p 的首行1
:first-childp:first-child父元素的第一個子元素 p2
:beforep:before在每個 p 內容之前插入內容2
:afterp:after在每個 p 內容之後插入內容2
:lang(language)p:lang(it)lang 值以 "it" 開頭的 p2
element1~element2p~ul前面有 p 的每個 ul3
[attribute^=value]a[src^="https"]src 以 "https" 開頭的 a3
[attribute$=value]a[src$=".pdf"]src 以 ".pdf" 結尾的 a3
[attribute*=value]a[src*="abc"]src 含 "abc" 子串的 a3
:first-of-typep:first-of-type父元素的首個 p3
:last-of-typep:last-of-type父元素的最後一個 p3
:only-of-typep:only-of-type父元素唯一的 p3
:only-childp:only-child父元素唯一的子元素 p3
:nth-child(n)p:nth-child(2)父元素的第二個子元素 p3
:nth-last-child(n)p:nth-last-child(2)從最後一個子元素起數的第二個3
:nth-of-type(n)p:nth-of-type(2)父元素第二個 p3
:nth-last-of-type(n)p:nth-last-of-type(2)從最後起數的第二個 p3
:last-childp:last-child父元素最後一個子元素 p3
:root:root文檔的根元素3
:emptyp:empty沒有子元素的 p(含文本節點)3
:target#news:target當前活動的 #news3
:enabledinput:enabled每個啟用的 input3
:disabledinput:disabled每個禁用的 input3
:checkedinput:checked每個被選中的 input3
:not(selector):not(p)非 p 的每個元素3
::selection::selection被用戶選取的元素部分3
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved