1. 程式人生 > >JQuery之CSS選擇器

JQuery之CSS選擇器

1.選擇物件

1).基本

·#id 根據給定的ID匹配一個元素。例如:(“#id”)  
·element 根據給定的元素名匹配所有元素。例如:
(“div”)
·.class 根據給定的類匹配元素。例如:(.style1);(“*”)
·selector1,selector2,selectorN 將每一個選擇器匹配到的元素合併後一起返回。例如:$(“#id,div,.style1”)

2).表單

·:button 匹配所有按鈕。例如:(:button):checkbox(“:checkbox”)
·:file 匹配所有檔案域。例如:(

:file):hiddentypehidden(“input:hidden”)
·:image 匹配所有影象域。例如:(:image):inputinput,textarea,selectbutton(“:input”)
·:password 匹配所有密碼框。例如:(:password):radio(“:radio”)
·:reset 匹配所有重置按鈕。例如:(:reset):submit(“:submit”)
·:text 匹配所有的單行文字框。例如:(
:text):headerh1,h2,h3
(“:header”).css(“background”, “#EEE”);

2.篩選條件

1).屬性篩選

·[attribute*=value] 匹配給定的屬性是以包含某些值的元素。例如:(input[name=man)[attribute!=value](input[name!=’man’);
·[attribute=value]